How to use the splinter.element_list.ElementList function in splinter

To help you get started, we’ve selected a few splinter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / PyPOM / tests / splinter_specific / test_region.py View on Github external
def test_find_element_splinter(self, page, splinter, splinter_strategy):
        locator = (splinter_strategy, str(random.random()))
        from splinter.element_list import ElementList

        page.driver.configure_mock(
            **{"find_by_{0}.return_value".format(splinter_strategy): ElementList([])}
        )
        Region(page).find_element(*locator)
        getattr(
            page.driver, "find_by_{0}".format(splinter_strategy)
        ).assert_called_once_with(locator[1])
github cobrateam / splinter / tests / within_elements.py View on Github external
def test_element_should_be_a_elementList(self):
        "should be element list"
        element = self.browser.within('body')
        assert isinstance(element, ElementList)
github mozilla / PyPOM / tests / splinter_specific / test_region.py View on Github external
def test_is_element_present_not_present_splinter(self, region, splinter_strategy):
        from splinter.element_list import ElementList

        locator = (splinter_strategy, str(random.random()))
        with patch(
            "pypom.splinter_driver.Splinter.find_elements", new_callable=MagicMock()
        ) as mock_find_elements:
            mock_find_elements.return_value = ElementList([])
            assert not region.is_element_present(*locator)
github gabrielpjordao / pyfunct / tests / contrib / test_splinter_driver.py View on Github external
def test_fill_action_with_missing_element_raises(
        self,
        mocked_browser
    ):
        driver = self._get_driver(mocked_browser)
        element = ElementList([])
        with self.assertRaises(ActionNotPerformableException):
            driver.fill(element, 'some-text')
github mozilla / PyPOM / tests / splinter_specific / test_region.py View on Github external
def test_find_elements_splinter(self, page, splinter, splinter_strategy):
        locator = (splinter_strategy, str(random.random()))
        from splinter.element_list import ElementList

        page.driver.configure_mock(
            **{"find_by_{0}.return_value".format(splinter_strategy): ElementList([])}
        )
        Region(page).find_elements(*locator)
        getattr(
            page.driver, "find_by_{0}".format(splinter_strategy)
        ).assert_called_once_with(locator[1])
github cobrateam / splinter / tests / test_element_list.py View on Github external
def test_attribute_error_method_for_empty(self):
        """
        should raise ElementDoesNotExist when the list is empty
        and someone tries to access a method or property on the child element.
        """
        with self.assertRaises(ElementDoesNotExist):
            the_list = ElementList([])
            the_list.unknown_method()
github cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
def find_by_name(self, name):
        html = self.htmltree

        xpath = '//*[@name="%s"]' % name
        elements = []

        for xpath_element in html.xpath(xpath):
            elements.append(xpath_element)

        find_by = "name"
        query = xpath

        return ElementList(
            [LxmlControlElement(element, self) for element in elements],
            find_by=find_by,
            query=query,
        )
github ggozad / behaving / src / behaving / mobile / ios.py View on Github external
def find_by(self, finder, selector):
        elements = None
        end_time = time.time() + self.wait_time

        while time.time() < end_time:
            try:
                elements = finder(selector)
            except WebDriverException:
                elements = []
            if not isinstance(elements, list):
                elements = [elements]

            if elements:
                return ElementList(elements)
        return ElementList([])
github cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
def find_by_css(self, selector):
        elements = self._element.cssselect(selector)
        return ElementList([self.__class__(element, self) for element in elements])