How to use _wait_until_no_error method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

_waiting.py

Source:_waiting.py Github

copy

Full Screen

...48 if not present:49 return50 else:51 return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout))52 self._wait_until_no_error(timeout, check_present)53 def wait_until_page_contains_element(self, locator, timeout=None, error=None):54 """Waits until element specified with `locator` appears on current page.55 Fails if `timeout` expires before the element appears. See56 `introduction` for more information about `timeout` and its57 default value.58 `error` can be used to override the default error message.59 See also `Wait Until Page Contains`, `Wait For Condition`,60 `Wait Until Element Is Visible` and BuiltIn keyword `Wait Until61 Keyword Succeeds`.62 """63 if not error:64 error = "Element '%s' did not appear in <TIMEOUT>" % locator65 self._wait_until(timeout, error, self._is_element_present, locator)66 def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None):67 """Waits until element specified with `locator` disappears from current page.68 Fails if `timeout` expires before the element disappears. See69 `introduction` for more information about `timeout` and its70 default value.71 `error` can be used to override the default error message.72 See also `Wait Until Page Contains`, `Wait For Condition`,73 `Wait Until Element Is Visible` and BuiltIn keyword `Wait Until74 Keyword Succeeds`.75 """76 def check_present():77 present = self._is_element_present(locator)78 if not present:79 return80 else:81 return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout))82 self._wait_until_no_error(timeout, check_present)83 def wait_until_element_is_visible(self, locator, timeout=None, error=None):84 """Waits until element specified with `locator` is visible.85 Fails if `timeout` expires before the element is visible. See86 `introduction` for more information about `timeout` and its87 default value.88 `error` can be used to override the default error message.89 See also `Wait Until Page Contains`, `Wait Until Page Contains 90 Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword91 Succeeds`.92 """93 def check_visibility():94 visible = self._is_visible(locator)95 if visible:96 return97 elif visible is None:98 return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout))99 else:100 return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout))101 self._wait_until_no_error(timeout, check_visibility)102 103 def wait_until_element_is_not_visible(self, locator, timeout=None, error=None):104 """Waits until element specified with `locator` is not visible.105 Fails if `timeout` expires before the element is not visible. See106 `introduction` for more information about `timeout` and its107 default value.108 `error` can be used to override the default error message.109 See also `Wait Until Page Contains`, `Wait Until Page Contains 110 Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword111 Succeeds`.112 """113 def check_hidden():114 visible = self._is_visible(locator)115 if not visible:116 return117 elif visible is None:118 return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout))119 else:120 return error or "Element '%s' was still visible in %s" % (locator, self._format_timeout(timeout))121 self._wait_until_no_error(timeout, check_hidden)122 def wait_until_element_is_enabled(self, locator, timeout=None, error=None):123 """Waits until element specified with `locator` is enabled.124 Fails if `timeout` expires before the element is enabled. See125 `introduction` for more information about `timeout` and its126 default value.127 `error` can be used to override the default error message.128 See also `Wait Until Page Contains`, `Wait Until Page Contains129 Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword130 Succeeds`.131 """132 def check_enabled():133 element = self._element_find(locator, True, False)134 if not element:135 return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout))136 enabled = not element.get_attribute("disabled")137 if enabled:138 return139 else:140 return error or "Element '%s' was not enabled in %s" % (locator, self._format_timeout(timeout))141 self._wait_until_no_error(timeout, check_enabled)142 def wait_until_element_contains(self, locator, text, timeout=None, error=None):143 """Waits until given element contains `text`.144 Fails if `timeout` expires before the text appears on given element. See145 `introduction` for more information about `timeout` and its146 default value.147 `error` can be used to override the default error message.148 See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait For Condition`,149 `Wait Until Element Is Visible` and BuiltIn keyword `Wait Until150 Keyword Succeeds`.151 """152 element = self._element_find(locator, True, True)153 def check_text():154 actual = element.text155 if text in actual:156 return157 else:158 return error or "Text '%s' did not appear in %s to element '%s'. " \159 "Its text was '%s'." % (text, self._format_timeout(timeout), locator, actual)160 self._wait_until_no_error(timeout, check_text)161 def wait_until_element_does_not_contain(self, locator, text, timeout=None, error=None):162 """Waits until given element does not contain `text`.163 Fails if `timeout` expires before the text disappears from given element. See164 `introduction` for more information about `timeout` and its165 default value.166 `error` can be used to override the default error message.167 See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait For Condition`,168 `Wait Until Element Is Visible` and BuiltIn keyword `Wait Until169 Keyword Succeeds`.170 """171 element = self._element_find(locator, True, True)172 def check_text():173 actual = element.text174 if not text in actual:175 return176 else:177 return error or "Text '%s' did not disappear in %s from element '%s'." % (text, self._format_timeout(timeout), locator)178 self._wait_until_no_error(timeout, check_text)179 # Private180 def _wait_until(self, timeout, error, function, *args):181 error = error.replace('<TIMEOUT>', self._format_timeout(timeout))182 def wait_func():183 return None if function(*args) else error184 self._wait_until_no_error(timeout, wait_func)185 def _wait_until_no_error(self, timeout, wait_func, *args):186 timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs187 maxtime = time.time() + timeout188 while True:189 timeout_error = wait_func(*args)190 if not timeout_error: return191 if time.time() > maxtime:192 raise AssertionError(timeout_error)193 time.sleep(0.2)194 def _format_timeout(self, timeout):195 timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-appiumlibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful