How to use the splinter.driver.lxmldriver.LxmlControlElement 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 cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
def find_option_by_text(self, text):
        html = self.htmltree
        element = html.xpath('//option[normalize-space(text())="%s"]' % text)[0]
        control = LxmlControlElement(element.getparent(), self)
        return ElementList(
            [LxmlOptionElement(element, control)], find_by="text", query=text
        )
github cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
def find_option_by_value(self, value):
        html = self.htmltree
        element = html.xpath('//option[@value="%s"]' % value)[0]
        control = LxmlControlElement(element.getparent(), self)
        return ElementList(
            [LxmlOptionElement(element, control)], find_by="value", query=value
        )
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 cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
def find_by_xpath(self, xpath, original_find=None, original_selector=None):
        html = self.htmltree

        elements = []

        for xpath_element in html.xpath(xpath):
            if self._element_is_link(xpath_element):
                return self._find_links_by_xpath(xpath)
            elif self._element_is_control(xpath_element):
                elements.append((LxmlControlElement, xpath_element))
            else:
                elements.append((LxmlElement, xpath_element))

        find_by = original_find or "xpath"
        query = original_selector or xpath

        return ElementList(
            [element_class(element, self) for element_class, element in elements],
            find_by=find_by,
            query=query,
        )