class FirefoxLauncherTests(unittest.TestCase): def testLaunchAndCloseBrowser(self): self.webdriver = WebDriver() self.webdriver.quit() def testDoubleClose(self): self.webdriver = WebDriver() self.webdriver.close() self.webdriver.close() self.webdriver.quit()
class FirefoxLauncherTests (unittest.TestCase): def testLaunchAndCloseBrowser(self): self.webdriver = WebDriver() self.webdriver.quit() def testDoubleClose(self): self.webdriver = WebDriver() self.webdriver.close() self.webdriver.close() self.webdriver.quit()
class HomePageTest(TestCase): def _load_home_page(self): self.driver.get("http://127.0.0.1:8000/charts") def test_get_title(self): self.driver = WebDriver() self._load_home_page() title = self.driver.get_title() self.assertEquals("foobar", title) def tearDown(self): self.driver.quit()
class TestStaticPagesWithJs(unittest.TestCase): def setUp(self): self.server = Popen("dev_appserver.py . --port=80", shell=True) self.browser = WebDriver() def tearDown(self): self.browser.quit() # same as in python2.6 subprocess for posix systems (so currently no windows support) os.kill(self.server.pid, signal.SIGTERM) def test_index_with_js(self): self.browser.get('http://localhost') assert 'Welcome to Flask-Gae-Skeleton!' in self.browser.get_page_source( )
class TestStaticPagesWithJs(unittest.TestCase): def setUp(self): self.server = Popen("dev_appserver.py . --port=80", shell=True) self.browser = WebDriver() def tearDown(self): self.browser.quit() # same as in python2.6 subprocess for posix systems (so currently no windows support) os.kill(self.server.pid, signal.SIGTERM) def test_landing_index_with_js(self): self.browser.get('http://localhost') assert 'Welcome to Flask-Gae-Skeleton!' in self.browser.get_page_source()
def testAnonymousProfileIsFresh(self): driver = WebDriver() driver.get("http://localhost:%d/simpleTest.html" % WEB_SERVER_PORT) timestamp = time.mktime(datetime.datetime.now().timetuple()) + 100 cookie = {"name": "foo", "value": "bar", "expires": str(int(timestamp)) + "000", "domain": "localhost", "path": "/"} driver.add_cookie(utils.convert_cookie_to_json(cookie)) self.assertEquals(cookie, driver.get_cookies()[0]) driver.quit() driver = WebDriver() self.assertEquals([], driver.get_cookies()) driver.quit()
class ExampleTest2(unittest.TestCase): """This example shows how to use the page object pattern. For more information about this pattern, see: http://code.google.com/p/webdriver/wiki/PageObjects """ def setUp(self): self._driver = WebDriver() def tearDown(self): self._driver.quit() def testSearch(self): google = GoogleOneBox(self._driver, "http://www.google.com") res = google.search_for("cheese") self.assertTrue(res.link_contains_match_for("Wikipedia"))
def testAnonymousProfileIsFresh(self): driver = WebDriver() driver.get("http://localhost:%d/simpleTest.html" % WEB_SERVER_PORT) timestamp = time.mktime(datetime.datetime.now().timetuple()) + 100 cookie = { "name": "foo", "value": "bar", "expires": str(int(timestamp)) + "000", "domain": "localhost", "path": "/" } driver.add_cookie(utils.convert_cookie_to_json(cookie)) self.assertEquals(cookie, driver.get_cookies()[0]) driver.quit() driver = WebDriver() self.assertEquals([], driver.get_cookies()) driver.quit()
def testNamedProfile(self): profile = FirefoxProfile("example") driver = WebDriver(profile) driver.get("http://localhost:%d/simpleTest.html" % WEB_SERVER_PORT) self.assertEquals("Hello WebDriver", driver.get_title()) driver.quit()
def testAnonymousProfileExample(self): driver = WebDriver() driver.get("http://localhost:%d/simpleTest.html" % WEB_SERVER_PORT) self.assertEquals("Hello WebDriver", driver.get_title()) driver.quit()