Esempio n. 1
0
    def test_exists_return_False(self):
        driver = WebDriverMock()
        driver.expect("find_element_by_class_name", None)

        element = Element()
        element.driver = driver

        assert element.exists == False
Esempio n. 2
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
Esempio n. 3
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)
Esempio n. 4
0
    def test_exists_return_True(self):
        instance = WebElementMock()

        driver = WebDriverMock()
        driver.expect("find_element_by_class_name", instance)

        element = Element()
        element.driver = driver

        assert element.exists == True
Esempio n. 5
0
    def test_mouse_move_over_return_True(self):
        instance = WebElementMock()

        driver = WebDriverMock()
        driver.expect("find_element_by_xpath", instance)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.move_mouse_over() == True
        assert element.driver.called("execute") == 1
Esempio n. 6
0
    def test_alert_return_Alert(self):
        instance = AlertMock()
        instance.expect("text", "alert message!!")

        driver = WebDriverMock()
        driver.expect("switch_to_alert", instance)

        world.driver = driver

        alert = world.get_alert()
        assert alert.text == "alert message!!"
Esempio n. 7
0
    def test_enabled_return_False(self):
        instance = WebElementMock()
        instance.expect("is_enabled", False)

        driver = WebDriverMock()
        driver.expect("find_element_by_link_text", instance)

        element = Element()
        element.driver = driver

        assert element.enabled == False
Esempio n. 8
0
    def test_visible_return_False(self):
        instance = WebElementMock()
        instance.expect("is_displayed", False)

        driver = WebDriverMock()
        driver.expect("find_element_by_name", instance)

        element = Element()
        element.driver = driver

        assert element.visible == False
Esempio n. 9
0
    def test_tooltip_text_return_tooltip_text(self):
        instance = WebElementMock()
        instance.expect("get_attribute", "@title")

        driver = WebDriverMock()
        driver.expect("find_element_by_name", instance)

        element = Element(identifier="identifier")
        element.driver = driver

        assert element.title == "@title"
Esempio n. 10
0
    def test_get_instance_return_instance_by_id(self):
        instance = WebElementMock()
        instance.expect("tag_name", "input")

        driver = WebDriverMock()
        driver.expect("find_element_by_id", instance)

        element = Element(identifier="identifier")
        element.driver = driver

        assert element.get_instance().tag_name == instance.tag_name
Esempio n. 11
0
    def test_click_return_True(self):
        instance = WebElementMock()

        driver = WebDriverMock()
        driver.expect("find_element_by_xpath", instance)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.click() == True
        assert instance.called("click") == 1
Esempio n. 12
0
    def test_send_keys_by_script_return_True(self):
        instance = WebElementMock()

        driver = WebDriverMock()
        driver.expect("find_element_by_xpath", instance)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.send_keys_by_script("keystroke") == True
        assert element.driver.called("execute_script") == 1
Esempio n. 13
0
    def test_selected_return_False(self):
        instance = WebElementMock()
        instance.expect("is_selected", False)

        driver = WebDriverMock()
        driver.expect("find_element_by_id", instance)

        element = Element()
        element.driver = driver

        assert element.selected == False
Esempio n. 14
0
    def test_div_value_return_value_from_innerHTML(self):
        instance = WebElementMock()
        instance.expect("tag_name", "div")
        instance.expect("get_attribute", "@innerHTML")

        driver = WebDriverMock()
        driver.expect("find_element_by_xpath", instance)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.value == "@innerHTML"
Esempio n. 15
0
    def test_input_value_return_value_from_value(self):
        instance = WebElementMock()
        instance.expect("tag_name", "input")
        instance.expect("get_attribute", "@value")

        driver = WebDriverMock()
        driver.expect("find_element_by_id", instance)

        element = Element(identifier="identifier")
        element.driver = driver

        assert element.value == "@value"
Esempio n. 16
0
    def test_get_instances_return_element_list(self):
        elements = []
        elements.append(WebElementMock())
        elements.append(WebElementMock())

        driver = WebDriverMock()
        driver.expect("find_elements_by_xpath", elements)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.get_instances() == elements
Esempio n. 17
0
    def test_count_return_2(self):
        elements = []
        elements.append(WebElementMock())
        elements.append(WebElementMock())

        driver = WebDriverMock()
        driver.expect("find_elements_by_xpath", elements)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.count == 2
Esempio n. 18
0
    def test_select_return_True(self):
        options = []
        options.append(WebElementMock())
        options.append(WebElementMock())

        instance = WebElementMock()
        instance.expect("tag_name", "select")
        instance.expect("find_elements", options)

        driver = WebDriverMock()
        driver.expect("find_element_by_xpath", instance)

        element = Element("name", "identifier")
        element.driver = driver

        assert element.select("option") == True