Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_forward_to_none_page(self):
"should not fail when trying to forward to none"
browser = Browser('django')
browser.visit(EXAMPLE_APP)
browser.forward()
self.assertEqual(EXAMPLE_APP, browser.url)
browser.quit()
def test_quit(self):
"Browser.quit should call driver.quit"
with Mock() as mock:
mock.quit()
with Stub() as browser:
from splinter.driver import WebDriver
WebDriver() >> mock
browser = Browser()
browser.quit()
WebDriver.restore_import()
mock.validate()
def test_should_get_an_exception_and_format_it(self):
request = RequestHandler()
request.connect(EXAMPLE_APP + "page-that-doesnt-exists")
try:
request.ensure_success_response()
except HttpResponseError as e:
exception = e.msg
self.assertEqual("404 - Not Found", exception)
def test_visit(self):
"Browser.visit should call driver.visit"
with Mock() as mock:
mock.visit('http://foo.com')
with Stub() as browser:
from splinter.driver import WebDriver
WebDriver() >> mock
browser = Browser()
browser.visit('http://foo.com')
WebDriver.restore_import()
mock.validate()
def test_quit(self):
"Browser.quit should call driver.quit"
with Mock() as mock:
mock.quit()
with Stub() as browser:
from splinter.driver import WebDriver
WebDriver() >> mock
browser = Browser()
browser.quit()
WebDriver.restore_import()
mock.validate()
def test_visit(self):
"WebDriver.visit should call browser.get"
with Mock() as firefox_mock:
firefox_mock.get('http://foo.com')
with ReplaceBrowser(firefox_mock):
driver = WebDriver()
driver.visit('http://foo.com')
firefox_mock.validate()
def test_quit(self):
"Browser.quit should call driver.quit"
with Mock() as mock:
mock.quit()
with Stub() as browser:
from splinter.driver import WebDriver
WebDriver() >> mock
browser = Browser()
browser.quit()
WebDriver.restore_import()
mock.validate()
def test_quit(self):
"WebDriver.quit should call browser.quit"
with Mock() as firefox_mock:
firefox_mock.quit()
with ReplaceBrowser(firefox_mock):
driver = WebDriver()
driver.quit()
firefox_mock.validate()
settings, 'BDD_BROWSER_LANGUAGE', 'en-US'
)
}
if driver_name == 'firefox':
params.update({
'profile_preferences': language,
'capabilities': {'moz:webdriverClick': False},
})
elif driver_name == 'chrome':
load_entry_point('chromedriver-binary==74.0.3729.6.0', 'console_scripts', 'chromedriver-path')
options = Options()
options.add_experimental_option('prefs', language)
params.update({
'options': options
})
context.browser = Browser(**params)
def __init__(self, start_url):
imp = os.environ.get('WEBDRIVER', 'firfox')
if imp in ('firefox', 'ff'):
driver = 'firefox'
else:
driver = 'phantomjs'
self.b = splinter.Browser(driver)
self.d = self.b.driver
self.d.set_window_size(1400, 1000)
self.start_url = start_url