Exemplo n.º 1
0
 def test_is_element_displayed_splinter(self, page, splinter, splinter_strategy):
     root_element = MagicMock()
     root_element.configure_mock(
         **{"find_by_{0}.return_value.first.visible".format(splinter_strategy): True}
     )
     locator = (splinter_strategy, str(random.random()))
     region = Region(page, root=root_element)
     assert region.is_element_displayed(*locator)
Exemplo n.º 2
0
 def test_is_element_displayed_not_present(self, page, selenium):
     root_element = Mock()
     locator = (str(random.random()), str(random.random()))
     from selenium.common.exceptions import NoSuchElementException
     root_element.find_element.side_effect = NoSuchElementException()
     region = Region(page, root=root_element)
     assert not region.is_element_displayed(locator)
     root_element.find_element.assert_called_once_with(*locator)
     root_element.find_element.is_displayed.assert_not_called()
Exemplo n.º 3
0
 def test_is_element_displayed_hidden(self, page, selenium):
     root_element = Mock()
     locator = (str(random.random()), str(random.random()))
     hidden_element = root_element.find_element()
     hidden_element.is_displayed.return_value = False
     region = Region(page, root=root_element)
     assert not region.is_element_displayed(locator)
     root_element.find_element.assert_called_with(*locator)
     hidden_element.is_displayed.assert_called_once_with()
Exemplo n.º 4
0
 def test_is_element_displayed_hidden_selenium(self, page, selenium):
     root_element = Mock()
     locator = (str(random.random()), str(random.random()))
     hidden_element = root_element.find_element()
     hidden_element.is_displayed.return_value = False
     region = Region(page, root=root_element)
     assert not region.is_element_displayed(*locator)
     root_element.find_element.assert_called_with(*locator)
     hidden_element.is_displayed.assert_called_once_with()
Exemplo n.º 5
0
 def test_is_element_displayed_not_present_selenium(self, page, selenium):
     root_element = Mock()
     locator = (str(random.random()), str(random.random()))
     from selenium.common.exceptions import NoSuchElementException
     root_element.find_element.side_effect = NoSuchElementException()
     region = Region(page, root=root_element)
     assert not region.is_element_displayed(*locator)
     root_element.find_element.assert_called_once_with(*locator)
     root_element.find_element.is_displayed.assert_not_called()
Exemplo n.º 6
0
 def test_is_element_displayed_not_present_splinter(self, page, splinter,
                                                    splinter_strategy):
     root_element = Mock()
     locator = (splinter_strategy, str(random.random()))
     region = Region(page, root=root_element)
     from splinter.element_list import ElementList
     with patch('pypom.splinter_driver.Splinter.find_element',
                new_callable=MagicMock()) as mock_find_element:
         mock_find_element.return_value = ElementList([])
         assert not region.is_element_displayed(*locator)
Exemplo n.º 7
0
 def test_is_element_displayed_hidden_splinter(self, page, splinter,
                                               splinter_strategy):
     root_element = MagicMock()
     root_element.configure_mock(
         **{
             'find_by_{0}.return_value.first.visible'.format(splinter_strategy):
             False
         })
     locator = (splinter_strategy, str(random.random()))
     region = Region(page, root=root_element)
     assert not region.is_element_displayed(*locator)
Exemplo n.º 8
0
 def test_is_element_displayed_hidden_splinter(self, page, splinter,
                                               splinter_strategy):
     locator = (splinter_strategy, str(random.random()))
     hidden_element = splinter.find_element()
     hidden_element.is_displayed.return_value = False
     region = Region(page)
     with patch('pypom.splinter_driver.Splinter.find_element',
                new_callable=Mock()) as mock_find_element:
         visible_mock = Mock().visible.return_value = False
         first_mock = Mock().first.return_value = visible_mock
         mock_find_element.return_value = first_mock
         assert not region.is_element_displayed(*locator)
Exemplo n.º 9
0
    def test_is_element_displayed_not_present_splinter(
        self, page, splinter, splinter_strategy
    ):
        root_element = Mock()
        locator = (splinter_strategy, str(random.random()))
        region = Region(page, root=root_element)
        from splinter.element_list import ElementList

        with patch(
            "pypom.splinter_driver.Splinter.find_element", new_callable=MagicMock()
        ) as mock_find_element:
            mock_find_element.return_value = ElementList([])
            assert not region.is_element_displayed(*locator)
Exemplo n.º 10
0
 def test_is_element_displayed_hidden_splinter(
     self, page, splinter, splinter_strategy
 ):
     locator = (splinter_strategy, str(random.random()))
     hidden_element = splinter.find_element()
     hidden_element.is_displayed.return_value = False
     region = Region(page)
     with patch(
         "pypom.splinter_driver.Splinter.find_element", new_callable=Mock()
     ) as mock_find_element:
         visible_mock = Mock().visible.return_value = False
         first_mock = Mock().first.return_value = visible_mock
         mock_find_element.return_value = first_mock
         assert not region.is_element_displayed(*locator)