Example #1
0
 def wait_element_text_visible(self, by, value, text):
     try:
         WaitUtils.wait_for_element_text_visible(self.driver, by, value,
                                                 text)
         return True
     except Exception as e:
         return False
Example #2
0
 def find_element(self, by, value):
     try:
         return self._appium_context().find_element(by, value)
     except Exception as handleRetry:
         self._refresh()
         WaitUtils.wait_for_element_present(self._appium_context(), by, value)
         return self._appium_context().find_element(by, value)
 def find_element_sendkeys(self, by, value, keys):
     try:
         self.driver.find_element(by, value).send_keys(keys)
     except Exception as handleRetry:
         try:
             WaitUtils.wait_for_element_visible(self.driver, by, value)
             self.driver.find_element(by, value).send_keys(keys)
         except Exception as e:
             raise e
 def find_element_click(self, by, value):
     try:
         self.driver.find_element(by, value).click()
     except Exception as handleRetry:
         try:
             WaitUtils.wait_for_element_clickable(self.driver, by, value)
             self.driver.find_element(by, value).click()
         except Exception as e:
             raise e
Example #5
0
 def check_element_enabled(self, by, value):
     try:
         return self.driver.find_element(by, value).is_enabled()
     except Exception as handleRetry:
         try:
             WaitUtils.wait_for_element_visible(self.driver, by, value)
             return self.driver.find_element(by, value).is_enabled()
         except Exception as e:
             return False
Example #6
0
 def __find_elements(self, by, value):
     try:
         try:
             return self._appium_context().find_elements(by, value)
         except Exception as handleRetry:
             self._refresh()
             WaitUtils.wait_for_element_present(self._appium_context(), by, value)
             return self._appium_context().find_elements(by, value)
     except Exception as e:
         raise Exception("Cannot find element by [%s] under: \n %s \n" % (value, self))
Example #7
0
 def find_elements(self, by, value, number=1):
     try:
         if len(self.__find_elements(by, value)) >= number:
             return self.__find_elements(by, value)
         else:
             raise Exception
     except Exception as handleRetry:
         self._refresh()
         WaitUtils.wait_for_elements_number_right(self._appium_context(), by, value, number)
         return self.__find_elements(by, value)
 def find_flutter_element_sendkeys(self, locator, value):
     try:
         WaitUtils.flutter_wait_for_element(self.driver, value)
         self.driver.elementSendKeys(locator, value)
     except Exception as handleRetry:
         try:
             WaitUtils.flutter_wait_for_element(self.driver, value)
             self.driver.elementSendKeys(locator, value)
         except Exception as e:
             raise NoSuchElementException
 def element_exist(self, by, value):
     try:
         self.driver.find_element(by, value)
         return True
     except Exception as handleRetry:
         try:
             WaitUtils.wait_for_element_present(self.driver, by, value)
             self.driver.find_element(by, value)
         except Exception as e:
             raise e
 def flutter_scroll_to_text(self, value):
     try:
         WaitUtils.flutter_wait_for_element(self.driver, value)
         self.driver.execute_script("flutter:scrollIntoView", value, 0.1)
     except Exception as handleRetry:
         try:
             WaitUtils.flutter_wait_for_element(self.driver, value)
             self.driver.execute_script("flutter:scrollIntoView", value,
                                        0.1)
         except Exception as e:
             raise NoSuchElementException
Example #11
0
 def find_flutter_element(self, value):
     try:
         WaitUtils.flutter_wait_for_element(self._appium_context(), value)
         return FlutterElement(self._appium_context(), value)
     except Exception as handleRetry:
         try:
             WaitUtils.flutter_wait_for_element(self._appium_context(),
                                                value)
             return FlutterElement(self._appium_context(), value)
         except Exception as e:
             raise e
Example #12
0
 def make_sure_element_exist(self, by, value, interval=5, timeout=20):
     try:
         self.driver._appium_context().find_element(by, value)
         return True
     except Exception as handleRetry:
         try:
             WaitUtils.wait_for_element_present(
                 self.driver._appium_context(),
                 by,
                 value,
                 interval=interval,
                 timeout=timeout)
             return True
         except Exception:
             return False
Example #13
0
    def _find_web_elements(self, by, value, identifier=None):
        from .WebElement.DynamicElement import DynamicElement
        try:
            web_elements = self._selenium_context().find_elements(by, value)
            print("The first find elements number is " + str(web_elements))
        except Exception as handleRetry:
            self._refresh()
            WaitUtils.wait_for_element_present(self._selenium_context(), by,
                                               value)
            web_elements = self._selenium_context().find_elements(by, value)
            print("The second find elements number is " + str(web_elements))

        elements = []
        for web_element in web_elements:
            elements.append(DynamicElement(self, web_element, identifier))
        return elements
Example #14
0
 def get_element_text(self, by, value):
     try:
         return self.driver.find_element(by, value).text
     except Exception as handleRetry:
         WaitUtils.wait_for_element_visible(self.driver, by, value)
         return self.driver.find_element(by, value).text
Example #15
0
 def clear_element_value(self, by, value):
     try:
         self.driver.find_element(by, value).clear()
     except Exception as handleRetry:
         WaitUtils.wait_for_element_present(self.driver, by, value)
         self.driver.find_element(by, value).clear()