Python selenium.webdriver.support.expected_conditions.invisibility_of_element_located() Examples
The following are 16
code examples of selenium.webdriver.support.expected_conditions.invisibility_of_element_located().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.webdriver.support.expected_conditions
, or try the search function
.
Example #1
Source File: WebRunner.py From PyWebRunner with MIT License | 6 votes |
def wait_for_invisible(self, selector='', **kwargs): ''' Wait for an element to be invisible. Parameters ---------- selector: str A CSS selector to search for. This can be any valid CSS selector. kwargs: Passed on to _wait_for ''' if selector.startswith('/'): by = By.XPATH else: by = By.CSS_SELECTOR self._wait_for(EC.invisibility_of_element_located((by, selector)), **kwargs)
Example #2
Source File: actions.py From gigantum-client with MIT License | 6 votes |
def delete_dataset_cloud(driver: selenium.webdriver, dataset_title): """ Delete a dataset from cloud. Args: driver dataset """ logging.info(f"Removing dataset {dataset_title} from cloud") driver.find_element_by_xpath("//a[contains(text(), 'Datasets')]").click() driver.find_element_by_css_selector(".Datasets__nav-item--cloud").click() time.sleep(2) driver.find_element_by_css_selector(".RemoteDatasets__icon--delete").click() driver.find_element_by_css_selector("#deleteInput").send_keys(dataset_title) time.sleep(2) driver.find_element_by_css_selector(".ButtonLoader").click() time.sleep(5) wait = WebDriverWait(driver, 200) wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".DeleteDataset")))
Example #3
Source File: __init__.py From ontask_b with MIT License | 6 votes |
def wait_for_page(self, title=None, element_id=None): if title: WebDriverWait(self.selenium, 10).until( EC.title_is(title) ) WebDriverWait(self.selenium, 10).until( EC.presence_of_element_located((By.ID, 'div-spinner')) ) WebDriverWait(self.selenium, 10).until( EC.invisibility_of_element_located((By.ID, 'img-spinner')) ) if element_id: WebDriverWait(self.selenium, 10).until( EC.presence_of_element_located((By.ID, element_id)) )
Example #4
Source File: common.py From bitmask-dev with GNU General Public License v3.0 | 5 votes |
def wait_until_element_is_invisible_by_locator(context, locator_tuple, timeout=TIMEOUT_IN_S): wait = WebDriverWait(context.browser, timeout) wait.until(EC.invisibility_of_element_located(locator_tuple))
Example #5
Source File: tests.py From bioforum with MIT License | 5 votes |
def wait_until_invisible(self, css_selector, timeout=10): """ Block until the element described by the CSS selector is invisible. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec self.wait_until( ec.invisibility_of_element_located((By.CSS_SELECTOR, css_selector)), timeout )
Example #6
Source File: SeleniumHelper.py From twitter-accounts-creator-bot with MIT License | 5 votes |
def waitHideElement(self, selector, wait): try: wait = WebDriverWait(self.driver, wait) element = wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, selector))) return element except: return None
Example #7
Source File: tests.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def wait_until_invisible(self, css_selector, timeout=10): """ Block until the element described by the CSS selector is invisible. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec self.wait_until( ec.invisibility_of_element_located((By.CSS_SELECTOR, css_selector)), timeout )
Example #8
Source File: tests.py From python with Apache License 2.0 | 5 votes |
def wait_until_invisible(self, css_selector, timeout=10): """ Block until the element described by the CSS selector is invisible. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec self.wait_until( ec.invisibility_of_element_located((By.CSS_SELECTOR, css_selector)), timeout )
Example #9
Source File: elements.py From gigantum-client with MIT License | 5 votes |
def wait_to_disappear(self, nsec: int = 20): """Wait until the element disappears.""" t0 = time.time() try: wait = WebDriverWait(self.driver, nsec) wait.until(expected_conditions.invisibility_of_element_located((By.CSS_SELECTOR, self.selector))) except Exception as e: tf = time.time() m = f'Timed out on {self.selector} after {tf - t0:.1f}sec' logging.error(m) if not str(e).strip(): raise ValueError(m) else: raise e
Example #10
Source File: tests.py From python2017 with MIT License | 5 votes |
def wait_until_invisible(self, css_selector, timeout=10): """ Block until the element described by the CSS selector is invisible. """ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec self.wait_until( ec.invisibility_of_element_located((By.CSS_SELECTOR, css_selector)), timeout )
Example #11
Source File: common.py From pixelated-user-agent with GNU Affero General Public License v3.0 | 5 votes |
def wait_until_element_is_invisible_by_locator(context, locator_tuple, timeout=TIMEOUT_IN_S): wait = WebDriverWait(context.browser, timeout) wait.until(EC.invisibility_of_element_located(locator_tuple))
Example #12
Source File: SeleniumHelper.py From linkedin-profile-scraper with MIT License | 5 votes |
def waitHideElement(self, selector, wait): try: wait = WebDriverWait(self.driver, wait) element = wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, selector))) return element except: return None
Example #13
Source File: test_assignment_list.py From nbgrader with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _wait_for_list(browser, name, num_rows): _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#{}_assignments_list_loading".format(name)))) _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#{}_assignments_list_placeholder".format(name)))) _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#{}_assignments_list_error".format(name)))) _wait(browser).until(lambda browser: len(browser.find_elements_by_css_selector("#{}_assignments_list > .list_item".format(name))) == num_rows) rows = browser.find_elements_by_css_selector("#{}_assignments_list > .list_item".format(name)) assert len(rows) == num_rows return rows
Example #14
Source File: test_course_list.py From nbgrader with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _wait_for_list(browser, num_rows): _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#formgrader_list_loading"))) _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#formgrader_list_placeholder"))) _wait(browser).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "#formgrader_list_error"))) _wait(browser).until(lambda browser: len(browser.find_elements_by_css_selector("#formgrader_list > .list_item")) == num_rows) rows = browser.find_elements_by_css_selector("#formgrader_list > .list_item") assert len(rows) == num_rows return rows
Example #15
Source File: requestium.py From requestium with BSD 3-Clause "New" or "Revised" License | 4 votes |
def ensure_element(self, locator, selector, state="present", timeout=None): """This method allows us to wait till an element appears or disappears in the browser The webdriver runs in parallel with our scripts, so we must wait for it everytime it runs javascript. Selenium automatically waits till a page loads when GETing it, but it doesn't do this when it runs javascript and makes AJAX requests. So we must explicitly wait in that case. The 'locator' argument defines what strategy we use to search for the element. The 'state' argument allows us to chose between waiting for the element to be visible, clickable, present, or invisible. Presence is more inclusive, but sometimes we want to know if the element is visible. Careful, its not always intuitive what Selenium considers to be a visible element. We can also wait for it to be clickable, although this method is a bit buggy in selenium, an element can be 'clickable' according to selenium and still fail when we try to click it. More info at: http://selenium-python.readthedocs.io/waits.html """ locators = {'id': By.ID, 'name': By.NAME, 'xpath': By.XPATH, 'link_text': By.LINK_TEXT, 'partial_link_text': By.PARTIAL_LINK_TEXT, 'tag_name': By.TAG_NAME, 'class_name': By.CLASS_NAME, 'css_selector': By.CSS_SELECTOR} locator = locators[locator] if not timeout: timeout = self.default_timeout if state == 'visible': element = WebDriverWait(self, timeout).until( EC.visibility_of_element_located((locator, selector)) ) elif state == 'clickable': element = WebDriverWait(self, timeout).until( EC.element_to_be_clickable((locator, selector)) ) elif state == 'present': element = WebDriverWait(self, timeout).until( EC.presence_of_element_located((locator, selector)) ) elif state == 'invisible': WebDriverWait(self, timeout).until( EC.invisibility_of_element_located((locator, selector)) ) element = None else: raise ValueError( "The 'state' argument must be 'visible', 'clickable', 'present' " "or 'invisible', not '{}'".format(state) ) # We add this method to our element to provide a more robust click. Chromedriver # sometimes needs some time before it can click an item, specially if it needs to # scroll into it first. This method ensures clicks don't fail because of this. if element: element.ensure_click = partial(_ensure_click, element) return element
Example #16
Source File: legoshop.py From lego-mindstorms-ev3-comparison with GNU General Public License v3.0 | 4 votes |
def _process_login(self): """ Manage LEGO Shop login form return boolean """ # login stuff # if self.username and self.password: print("* Let's log in with LEGO ID {user}.".format(user=self.username)) login_link = self.wait.until(EC.element_to_be_clickable( (By.CSS_SELECTOR, ".legoid-box .links > a[data-uitest='login-link']"))) login_link.click() self.browser.switch_to.frame('legoid-iframe') self.wait.until(EC.invisibility_of_element_located( (By.XPATH, "//div[@id='accountLoader']"))) user_input = self.wait.until(EC.element_to_be_clickable( (By.ID, 'fieldUsername'))) user_input.click() user_input.send_keys(self.username) passwd_input = self.wait.until(EC.element_to_be_clickable( (By.ID, 'fieldPassword'))) passwd_input.click() passwd_input.send_keys(self.password) login_button = self.browser.find_element_by_id('buttonSubmitLogin') login_button.click() self.browser.switch_to.default_content() # ensure the user/password are good try: self.wait.until(EC.element_to_be_clickable( (By.CSS_SELECTOR, ".legoid-box .links > a[data-uitest='logout-link']") )) print("login success!") return True except TimeoutException: print("login failed!") # close the browser and stop here self.browser.quit() return False else: print("!!! credentials are not defined") return True