예제 #1
0
 def find_element_by_id(self, id_):
     """Finds element by id."""
     try:
         resp = self._post("element", "id", id_)
         return self._get_elem(resp[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)
예제 #2
0
 def _find_element_by(self, by, value):
     try:
         resp = self._post("element", by, value)
         if not resp:
             raise NoSuchElementException(resp)
         return self._get_elem(resp[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)
예제 #3
0
    def find_element_by_link_text(self, link):
        """Finds an element by its link text.

        Returns None if the element is not a link.
        """
        try:
            return self._get_elem(self._post("element", "link text", link)[0])
        except ErrorInResponseException, ex:
            utils.handle_find_element_exception(ex)
예제 #4
0
 def _get_elem_by(self, by, value):
     try:
         resp = self._post(urllib.quote("element/%s" % by),
                           {"using": by, "value": value})
         if not resp:
             raise NoSuchElementException()
         return self._get_elem(resp[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)
예제 #5
0
 def find_element_by_xpath(self, xpath):
     """Finds element by xpath."""
     try:
         return self._get_elem(self._post("element/xpath", {"using": "xpath", "value": xpath})[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)
예제 #6
0
 def find_element_by_name(self, name):
     """Finds and element by its name."""
     try:
         return self._get_elem(self._post("element", "name", name)[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)
예제 #7
0
 def find_element_by_xpath(self, xpath):
     """Finds an element by xpath."""
     try:
         return self._get_elem(self._post("element", "xpath", xpath)[0])
     except ErrorInResponseException, ex:
         utils.handle_find_element_exception(ex)