how to avoid google search detect selenium webdriver as unusual behaviour?

It appear that google detect browser profile to determine something strange has going on or not. for example if you do private browsing with your browser(i test it with firefox and chrome), your browser profile will change to anonymous, so google will find it suspicious and request you to fill captcha.

That case also happen when you run your browser from selenium webdriver.

So you need to set the selenium driver profile to your default profile by using some code like this(currently only work on firefox)

ProfilesIni allProfiles = new ProfilesIni();
WebDriver driver = new FirefoxDriver(allProfiles.getProfile("default"));