def test_find_element_return_Element(self): element = Element("search button", "xpath") page = Page("google", "http://www.google.com") page.elements["search button"] = element assert page.find_element("search button") == element
def test_go_return_True(self): driver = WebDriverMock() page = Page("google", "http://www.google.com") page.driver = driver assert page.go() == True assert page.driver.called("get") == 1
def test_wait_for_loading_return_True(self): driver = WebDriverMock() driver.expect("window_handles", [1, 2, 3]) driver.expect("current_url", "http://www.google.com") page = Page("google", "http://www.google.com") page.driver = driver assert page.wait_for_loading(timeout=0) == True
def test_wait_for_loading_return_False(self): driver = WebDriverMock() driver.expect("window_handles", [1, 2, 3]) driver.expect("current_url", "http://www.google.co.th") page = Page("google", "http://www.google.com") page.driver = driver with pytest.raises(RuntimeError): page.wait_for_loading(timeout=0)
def test_find_element_return_None(self): page = Page("google", "http://www.google.com") assert page.find_element("search button") == None
def test_get_url_return_url_with_path(self): page = Page("google", "http://www.google.com") page.url_paths = {"login":"******"} assert page.get_url("login") == "http://www.google.com/login"
def test_get_url_return_url(self): page = Page("google", "http://www.google.com") assert page.get_url() == "http://www.google.com"