Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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)
Пример #5
0
 def test_find_element_return_None(self):
     page = Page("google", "http://www.google.com")
     assert page.find_element("search button") == None
Пример #6
0
    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"
Пример #7
0
 def test_get_url_return_url(self):
     page = Page("google", "http://www.google.com")
     assert page.get_url() == "http://www.google.com"