Can a website detect when you are using selenium with geckodriver?

纵然是瞬间 提交于 2019-12-23 04:41:48

问题


Is it possible to detect instances of firefox browsers that are being controlled by Selenium and geckodriver?

Note there is a corresponding answer for chromedriver, but I'd like to know whether this is possible for firefox/geckodriver.


回答1:


Yes you can detect geckodriver controlled selenium with a simple check in JavaScript

var runningSelenium = !("showModalDialog" in window);



回答2:


As others have pointed out, there are a variety of different ways that a site can fingerprint and detect that you are running a browser that has been automated by selenium. Luckily though, some of the detection mechanisms are remarkably simple and just look for a bunch of environmental defaults, such as the screen size etc.

For example, when using Selenium for testing the app OAUTH sign-up sequences for Dropbox etc, the CAPTCHA stage can be avoided by just setting the screen to a non-default value (and offsetting the browser window to simulate a taskbar):

@@headless = Headless.new( dimensions: '1600x1200x24' )
@@headless.start
browser = Watir::Browser.new :firefox
width = browser.execute_script( 'return screen.width;' )
height = browser.execute_script( 'return screen.height;' ) - 95
browser.driver.manage.window.resize_to( width, height )
browser.driver.manage.window.move_to( 0,0 ) 


来源:https://stackoverflow.com/questions/46506961/can-a-website-detect-when-you-are-using-selenium-with-geckodriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!