示例#1
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"
示例#2
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
示例#3
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
示例#4
0
    def test_send_keys_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("keystroke") == True
        assert instance.called("send_keys") == 1
示例#5
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
示例#6
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
示例#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
示例#8
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"
示例#9
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"
示例#10
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