Esempio n. 1
0
def test_is_present_always_refreshes_dom_element(browser):
    el = WebElement(browser, "some_tag[@some_attr='some_value']")
    el._find_dom_element = Mock(wraps=el._find_dom_element)  # pylint: disable=protected-access
    dom_el = el.dom_element
    el.is_present()
    assert el.dom_element is not dom_el
    assert el._find_dom_element.call_count == 2  # pylint: disable=protected-access
Esempio n. 2
0
def test_is_not_displayed_when_dom_element_is_stale_and_no_more_present(
        browser, stale_dom_element):
    browser.find_elements_by_xpath.side_effect = ([stale_dom_element], [])
    el = WebElement(browser, "some_tag[@some_attr='some_value']")
    el._find_dom_element = Mock(wraps=el._find_dom_element)  # pylint: disable=protected-access
    assert el.dom_element is stale_dom_element
    assert not el.is_displayed()
    assert el._find_dom_element.call_count == 2  # pylint: disable=protected-access
    stale_dom_element.is_displayed.assert_called_once()
Esempio n. 3
0
def test_subsequent_accesses_to_dom_element_use_cached_object(browser):
    el = WebElement(browser, "some_tag[@some_attr='some_value']")
    el._find_dom_element = Mock(wraps=el._find_dom_element)  # pylint: disable=protected-access
    dom_el = el.dom_element
    assert el.dom_element is dom_el
    el._find_dom_element.assert_called_once()  # pylint: disable=protected-access
Esempio n. 4
0
def test_loading_dom_element_for_the_first_time(browser):
    el = WebElement(browser, "some_tag[@some_attr='some_value']")
    el._find_dom_element = Mock(wraps=el._find_dom_element)  # pylint: disable=protected-access
    dom_el = el.dom_element
    assert dom_el is not None
    el._find_dom_element.assert_called_once()  # pylint: disable=protected-access