def get_firefox_driver(path = None, selenium_grid_hub = None, no_proxy=False):
if selenium_grid_hub:
desired_capabilities={
"browserName": "firefox",
"javascriptEnabled": True,
"proxy": {
"proxyType": "direct" if no_proxy else "system"
}
}
profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.phishy-userpass-length", 255);
return webdriver.Remote(command_executor=selenium_grid_hub, desired_capabilities=desired_capabilities, browser_profile=profile)
else:
binary = None
if path:
binary = FirefoxBinary(path) #, log_file=open("/tmp/bat_firefox", 'a'))
profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.phishy-userpass-length", 255);
profile.set_preference("network.proxy.type", 0)
capabilities = None
if USE_MARIONETTE:
# tell webdriver to use Marionette instead of plain Firefox
capabilities = DesiredCapabilities.FIREFOX
capabilities["marionette"] = True
return webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, capabilities=capabilities)
评论列表
文章目录