当前位置: 首页>>代码示例>>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;未经允许,请勿转载。