Every line of 'webdriverwait 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.
1716 def 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,])
52 def 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)
94 def 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
240 def 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)
181 def wait(self, timeout=0): 182 if timeout == 0: 183 timeout = random.randint(25, 30) 184 return WebDriverWait(self.driver, timeout)
177 @browser_test() 178 def 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)
170 def 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
80 def 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
529 def wait_for_element_condition(self, element, ms, negative, condition): 530 """ 531 Wait on an element until a certain condition is met, up to a maximum amount of time to wait. 532 533 :param element: CSS Selector or XPATH used to locate the element 534 :param ms: maximum time (in milliseconds) to wait for the condition to be true 535 :param negative: whether or not the check for negation of condition. Will coarse boolean from value 536 :param condition: the condition to check for. Defaults to checking for presence of element 537 :return: element 538 """ 539 if not ms: 540 seconds = self.default_wait 541 else: 542 seconds = round(ms / 1000, 3) 543 544 condition_text_map = { 545 'be checked': element_is_selected, 546 'be enabled': element_is_enabled, 547 'be selected': element_is_selected, 548 'be visible': element_is_visible, 549 'contain a text': element_contains_text, 550 'contain a value': element_contains_value, 551 'exist': element_is_present, 552 } 553 554 if condition: 555 expected = condition_text_map[condition] 556 else: 557 expected = element_is_present 558 559 if element.startswith('/'): 560 locator = (By.XPATH, element) 561 else: 562 locator = (By.CSS_SELECTOR, element) 563 564 wait = WebDriverWait(self, seconds) 565 566 try: 567 result = wait.until(expected(locator, negative=bool(negative))) 568 except TimeoutException: 569 result = None 570 571 return result
227 def 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)