當前位置: 首頁>>代碼示例>>Python>>正文


Python expected_conditions.invisibility_of_element_located方法代碼示例

本文整理匯總了Python中selenium.webdriver.support.expected_conditions.invisibility_of_element_located方法的典型用法代碼示例。如果您正苦於以下問題:Python expected_conditions.invisibility_of_element_located方法的具體用法?Python expected_conditions.invisibility_of_element_located怎麽用?Python expected_conditions.invisibility_of_element_located使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.webdriver.support.expected_conditions的用法示例。


在下文中一共展示了expected_conditions.invisibility_of_element_located方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: wait_for_invisible

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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) 
開發者ID:IntuitiveWebSolutions,項目名稱:PyWebRunner,代碼行數:21,代碼來源:WebRunner.py

示例2: delete_dataset_cloud

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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"))) 
開發者ID:gigantum,項目名稱:gigantum-client,代碼行數:22,代碼來源:actions.py

示例3: wait_for_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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))
            ) 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:19,代碼來源:__init__.py

示例4: wait_until_element_is_invisible_by_locator

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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)) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:6,代碼來源:common.py

示例5: wait_until_invisible

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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
        ) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:12,代碼來源:tests.py

示例6: waitHideElement

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:toxtli,項目名稱:twitter-accounts-creator-bot,代碼行數:9,代碼來源:SeleniumHelper.py

示例7: wait_to_disappear

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:gigantum,項目名稱:gigantum-client,代碼行數:16,代碼來源:elements.py

示例8: wait_until_element_is_invisible_by_locator

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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)) 
開發者ID:pixelated,項目名稱:pixelated-user-agent,代碼行數:5,代碼來源:common.py

示例9: _wait_for_list

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:10,代碼來源:test_assignment_list.py

示例10: _wait_for_list

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:10,代碼來源:test_course_list.py

示例11: ensure_element

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:tryolabs,項目名稱:requestium,代碼行數:61,代碼來源:requestium.py

示例12: _process_login

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import invisibility_of_element_located [as 別名]
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 
開發者ID:bittner,項目名稱:lego-mindstorms-ev3-comparison,代碼行數:54,代碼來源:legoshop.py


注:本文中的selenium.webdriver.support.expected_conditions.invisibility_of_element_located方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。