Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpClass(cls):
global _browser
super(BrowserHarness, cls).setUpClass()
if _browser is None:
DriverClass = _DRIVERS[os.environ['WEBDRIVER_BROWSER']]
_browser = DriverClass()
atexit.register(_browser.quit)
cls._browser = _browser
def test_should_work_even_without_zope_testbrowser(self):
import __builtin__
old_import = __builtin__.__import__
def custom_import(name, *args, **kwargs):
if 'zope' in name:
return None
return old_import(name, *args, **kwargs)
__builtin__.__import__ = custom_import
from splinter import browser
reload(browser)
assert 'zope.testbrowser' not in browser._DRIVERS, 'zope.testbrowser driver should not be registered when zope.testbrowser is not installed'
browser.Browser('zope.testbrowser')
__builtin__.__import__ = old_import
while time.time() < end_time:
try:
if not self._is_text_present(text):
return True
except StaleElementReferenceException:
continue
return False
def fill(self, name, value):
field = self.find_by_accessibility_id(name).first
assert field, u'No elements found with accessibility id %s' % name
field.set_value(value)
_DRIVERS['android'] = AndroidWebDriver
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)
from splinter.browser import _DRIVERS
_DRIVERS['cordova'] = CordovaWebDriver
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)
from splinter.browser import _DRIVERS
_DRIVERS['firefox'] = WebDriver
"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)
from splinter.browser import _DRIVERS
_DRIVERS['chrome'] = WebDriver
while time.time() < end_time:
if not self._is_text_present(text):
return True
return False
def fill(self, name, value):
field = self.find_by_accessibility_id(name)
if not field:
field = self.find_by_ios_class_chain(
'**/XCUIElementTypeTextView[`name CONTAINS "%s"`]' % name)
assert field, u'No elements found with accessibility id or name %s' % name
field.first.set_value(value)
_DRIVERS['ios'] = IOSWebDriver