Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exclude switches in firefox webdriver options

Using Selenium and python, I can do this with Chrome webdriver:

options.add_experimental_option("excludeSwitches", ["enable-automation"])
driver = webdriver.Chrome(options = options)

but I can't find a similar attribute for Firefox's webdriver options. Does one exist?

like image 838
lucas Avatar asked Jul 20 '19 05:07

lucas


People also ask

How do I use Firefox options in selenium?

FirefoxOptions options = new FirefoxOptions(); driver = new RemoteWebDriver(new URL("http://10.x.x.x:4444/wd/hub"), options); When you start your Selenium Nodes, it displays a log information on using new FirefoxOptions preferred to 'DesiredCapabilities. firefox() along with all other browser options.


1 Answers

Firefox uses different flags. I am not sure exactly what your aim is but I am assuming you are trying to avoid some website detecting that you are using selenium.

There are different methods to avoid websites detecting the use of Selenium.

1) The value of navigator.webdriver is set to true by default when using Selenium. This variable will be present in Chrome as well as Firefox. This variable should be set to "undefined" to avoid detection.

2) A proxy server can also be used to avoid detection.

3) Some websites are able to use the state of your browser to determine if you are using Selenium. You can set Selenium to use a custom browser profile to avoid this.

The code below uses all three of these approaches.

profile = webdriver.FirefoxProfile('C:\\Users\\You\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\something.default-release')

PROXY_HOST = "12.12.12.123"
PROXY_PORT = "1234"
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", PROXY_HOST)
profile.set_preference("network.proxy.http_port", int(PROXY_PORT))
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
desired = DesiredCapabilities.FIREFOX

driver = webdriver.Firefox(firefox_profile=profile, desired_capabilities=desired)
like image 123
CST Avatar answered Sep 17 '22 06:09

CST