Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.add_argument('-F')
options.add_argument('--args')
options.add_argument('--disable-web-security')
if persistent_session:
options.add_argument('--user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova_browser')
else:
options.add_argument('--incognito')
dc = DesiredCapabilities.CHROME
dc['loggingPrefs'] = {'browser': 'ALL'}
self.driver = Chrome(chrome_options=options, desired_capabilities=dc, **kwargs)
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(CordovaWebDriver, self).__init__(wait_time)
firefox_options.add_argument("-private")
self.driver = Firefox(
firefox_profile,
capabilities=firefox_capabilities,
options=firefox_options,
timeout=timeout,
**kwargs
)
if fullscreen:
ActionChains(self.driver).send_keys(Keys.F11).perform()
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
def __init__(self, browser, wait_time=2):
self.driver = browser
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
def __init__(self, user_agent=None, wait_time=2, fullscreen=False,
**kwargs):
options = Options()
if user_agent is not None:
options.add_argument("--user-agent=" + user_agent)
if fullscreen:
options.add_argument('--kiosk')
self.driver = Chrome(chrome_options=options, **kwargs)
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
if profile_preferences:
for key, value in profile_preferences.items():
firefox_profile.set_preference(key, value)
if extensions:
for extension in extensions:
firefox_profile.add_extension(extension)
self.driver = Firefox(firefox_profile)
if fullscreen:
ActionChains(self.driver).send_keys(Keys.F11).perform()
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
def __init__(self, user_agent=None, load_images=True,
desired_capabilities=None, wait_time=2,
custom_headers={}, **kwargs):
capabilities = DesiredCapabilities.PHANTOMJS.copy()
if user_agent is not None:
capabilities['phantomjs.page.settings.userAgent'] = user_agent
capabilities['phantomjs.page.settings.loadImages'] = load_images
if isinstance(custom_headers, dict):
for name, value in custom_headers.items():
capabilities['phantomjs.page.customHeaders.%s' % name] = value
if desired_capabilities:
capabilities.update(desired_capabilities)
self.driver = PhantomJS(desired_capabilities=capabilities, **kwargs)
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
if fullscreen:
options.add_argument('--kiosk')
prefs = {"download": {
"default_directory": _DOWNLOAD_PATH,
"directory_upgrade": True,
"extensions_to_open": ""
}}
options.add_experimental_option("prefs", prefs)
self.driver = Chrome(chrome_options=options, **kwargs)
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)
if browser_name == "INTERNET EXPLORER":
browser_name = "INTERNETEXPLORER"
# If no desired capabilities specified, add default ones
caps = getattr(DesiredCapabilities, browser_name, {})
if kwargs.get('desired_capabilities'):
# Combine user's desired capabilities with default
caps.update(kwargs['desired_capabilities'])
kwargs['desired_capabilities'] = caps
self.driver = Remote(command_executor, **kwargs)
self.element_class = WebDriverElement
self._cookie_manager = CookieManager(self.driver)
super(WebDriver, self).__init__(wait_time)