10 examples of 'webdriverwait selenium python' in Python

Every line of 'webdriverwait selenium python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1716def wait_for_condition(self,script,timeout):
1717 """
1718 Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
1719 The snippet may have multiple lines, but only the result of the last line
1720 will be considered.
1721
1722
1723 Note that, by default, the snippet will be run in the runner's test window, not in the window
1724 of your application. To get the window of your application, you can use
1725 the JavaScript snippet ``selenium.browserbot.getCurrentWindow()``, and then
1726 run your JavaScript in there
1727
1728
1729 'script' is the JavaScript snippet to run
1730 'timeout' is a timeout in milliseconds, after which this command will return with an error
1731 """
1732 self.do_command("waitForCondition", [script,timeout,])
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

181def wait(self, timeout=0):
182 if timeout == 0:
183 timeout = random.randint(25, 30)
184 return WebDriverWait(self.driver, timeout)
240def wait_for_element(self, identifier, by=By.ID, timeout=5, visible=False):
241 visibility = EC.visibility_of_element_located
242 presence = EC.presence_of_element_located
243 loader = visibility if visible else presence
244 load = loader((by, identifier))
245 WebDriverWait(self.drv, timeout).until(load)
52def wait_for(self, interval=None, timeout=None):
53 """
54 Get a ElementWaitFor instance.
55
56 :param interval: the wait interval (in milliseconds). If None, use element's wait interval.
57 :param timeout: the wait timeout (in milliseconds). If None, use element's wait timeout.
58 """
59 _interval = self.get_wait_interval() if interval is None else interval
60 _timeout = self.get_wait_timeout() if timeout is None else timeout
61 return ElementWaitFor(self, _interval, _timeout)
94def until(driver):
95 result = driver.execute_script('return window.GETTEXT_TESTS_FINISHED;')
96 if result == -1:
97 raise JavascriptError(
98 **driver.execute_script('return window.GETTEXT_ERROR;')
99 )
100 else:
101 return result == expected
170def wait_for_element(browser, locator, timeout=12, poll_frequency=0.5):
171 '''
172 '''
173 try:
174 element = WebDriverWait(
175 browser, timeout, poll_frequency).until(
176 expected_conditions.presence_of_element_located(locator),
177 message='Element {} could not be found.'.format(locator[1]))
178 wait_for_ajax(browser, poll_frequency=poll_frequency)
179 return element
180 except TimeoutException as err:
181 print(
182 '{}: Waiting for element "{}" to display. {}'.format(
183 type(err).__name__,
184 locator[1],
185 err
186 ))
187 return None
177@browser_test()
178def test_wait_for_js():
179 if 'selenium' in browser.capabilities:
180 browser.open('/waitfor')
181 browser.cssselect('#counter')[0].click(
182 wait_for='js:window.exampleCount==100;', timeout=3000)
227def waitForElements(self, css_selector, timeout=DEFAULT_WAIT_TIMEOUT,
228 visible=None):
229 """ Waits for DOM elements matching the provided CSS selector to be
230 available.
231
232 Args:
233 - css_selector: CSS selector string
234
235 Kwargs:
236 - timeout: Operation timeout in seconds
237 - visible: Ensure elements visibility status:
238 * True: wait for visible elements only
239 * False: wait for invisible elements only
240 * None: skip visibility status checks
241
242 Returns: List of DOM elements
243 """
244 def get_element_checker(driver, visible):
245 locator = (By.CSS_SELECTOR, css_selector)
246 if visible is True:
247 return EC.visibility_of_element_located(locator)
248 if visible is False:
249 return EC.invisibility_of_element_located(locator)
250 return lambda _: driver.find_elements_by_css_selector(css_selector)
251
252 message = u"Couldn't find elems matching %s (visibility check: %s)" % (
253 css_selector, visible)
254 WebDriverWait(self, timeout, poll_frequency=.25).until(
255 get_element_checker(self, visible), message=message)
256
257 return self.find_elements_by_css_selector(css_selector)
80def wait_on_element(driver, xpath, timeout=120):
81 num = 0
82 while is_element_present(driver, xpath) is False:
83 if num >= timeout:
84 return False
85 else:
86 num += 1
87 time.sleep(1)
88 return True
63def wait_until_element_not_visible(self, locator, timeout=10):
64 '''
65 Search element by locator and wait until it is not visible
66 '''
67 # Remove implicit wait
68 self.driver.implicitly_wait(0)
69 # Wait for invisibility
70 WebDriverWait(self.driver, timeout).until(EC.invisibility_of_element_located(locator))
71 # Restore implicit wait from properties
72 self.set_implicit_wait()

Related snippets