def __init__(self, db): self.db = db self.display = Display(visible=0, size=(1024, 768)) # Latest Chrome on Windows self.fake_browser = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' # be able to setup a firefox profile self.ff_profile = old_webdriver.firefox.firefox_profile.FirefoxProfile() # sets the download notification off self.ff_profile.set_preference('browser.download.manager.showWhenStarting', False) # sets the user agent, latest windows chrome is most common self.ff_profile.set_preference('general.useragent.override', self.fake_browser) # sets to not show annoying download panels # set driver self.display.start() self.browser = webdriver.WebDriver(firefox_profile=self.ff_profile) self.urls = self.get_urls()
def test_reuse_browser_unset(self): browser = webdriverplus.WebDriver('firefox') browser.quit() other = webdriverplus.WebDriver('firefox') self.assertNotEqual(browser, other)
def test_reuse_browser_set(self): browser = webdriverplus.WebDriver('firefox', reuse_browser=True) browser.quit() other = webdriverplus.WebDriver('firefox', reuse_browser=True) self.assertEqual(browser, other)
def setUp(self): super(WebDriverPlusTests, self).setUp() self.driver = webdriverplus.WebDriver(browser, reuse_browser=True, **self.extra_webdriver_kwargs)