Ejemplo n.º 1
0
 def analyze_element(self):
     elms = self.form_elm.get_elms(name=self.elm_name)
     for elm in elms:
         elm_type = elm.get_attribute('type')
         if elm_type == 'hidden':
             continue
         return elm.tag_name, elm_type
     raise NoSuchElementException(_create_exception_msg(name=self.elm_name))
Ejemplo n.º 2
0
 def analyze_element(self):
     elms = self.form_elm.get_elms(name=self.elm_name)
     for elm in elms:
         elm_type = elm.get_attribute('type')
         if elm_type == 'hidden':
             continue
         return elm.tag_name, elm_type
     raise NoSuchElementException(_create_exception_msg(name=self.elm_name))
Ejemplo n.º 3
0
    def wait_for_element(self, timeout=10, message='', *args, **kwds):
        """
        Same as WebDriverWait(driver, timeout).until(lambda driver: driver.get_elm(...)),
        but appends useful message if it's not provided.
        """
        if not message:
            message = _create_exception_msg(*args, **kwds)
        self.wait(timeout).until(lambda driver: driver.get_elm(*args, **kwds), message=message)

        # Also return that element for which is waiting.
        elm = self.get_elm(*args, **kwds)
        return elm
Ejemplo n.º 4
0
 def get_elm(
     self,
     id_=None, class_name=None, name=None, tag_name=None, xpath=None,
     parent_id=None, parent_class_name=None, parent_name=None, parent_tag_name=None,
     css_selector=None
 ):
     elms = self.get_elms(
         id_, class_name, name, tag_name, xpath,
         parent_id, parent_class_name, parent_name, parent_tag_name,
         css_selector
     )
     if not elms:
         raise selenium_exc.NoSuchElementException(_create_exception_msg(
             id_, class_name, name, tag_name, xpath,
             parent_id, parent_class_name, parent_name, parent_tag_name,
             self.current_url,
         ))
     return elms[0]
Ejemplo n.º 5
0
 def _find_element_or_elements(self, callback, by, value):
     if by in self._by_to_string_param_map:
         msg = _create_exception_msg(**{
             self._by_to_string_param_map[by]: value,
             'url': self.current_url,
         })
     else:
         msg = ''
     try:
         return callback(self, by, value)
     except (
         selenium_exc.NoSuchElementException,
         selenium_exc.StaleElementReferenceException,
         selenium_exc.InvalidElementStateException,
         selenium_exc.ElementNotVisibleException,
         selenium_exc.ElementNotSelectableException,
     ) as exc:
         raise exc.__class__(msg)
def test_make_msg_with_url():
    assert 'No element <* id=id> found at http://example.com' == _create_exception_msg(id_='id', url='http://example.com')
Ejemplo n.º 7
0
def test_make_msg_with_url():
    assert 'No element <* id=id> found at http://example.com' == _create_exception_msg(
        id_='id', url='http://example.com')
 def test_make_msg_with_url(self):
     msg = _create_exception_msg(id_='id', url='http://example.com')
     self.assertEquals(msg, 'No element <* id=id> found at http://example.com')
 def test_make_msg_with_url(self):
     msg = _create_exception_msg(id_='id', url='http://example.com')
     self.assertEquals(msg,
                       'No element <* id=id> found at http://example.com')