当前位置: 首页>>代码示例>>Python>>正文


Python WebDriverWait.is_displayed方法代码示例

本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.is_displayed方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.is_displayed方法的具体用法?Python WebDriverWait.is_displayed怎么用?Python WebDriverWait.is_displayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.wait.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.is_displayed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wait_until_element_not_visible

# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_displayed [as 别名]
    def wait_until_element_not_visible(webdriver, locator_lambda_expression,
                                       timeout=WTF_TIMEOUT_MANAGER.NORMAL, sleep=0.5):
        """
        Wait for a WebElement to disappear.

        Args:
            webdriver (Webdriver) - Selenium Webdriver
            locator (lambda) - Locator lambda expression.

        Kwargs:
            timeout (number) - timeout period
            sleep (number) - sleep period between intervals.

        """
        # Wait for loading progress indicator to go away.
        try:
            stoptime = datetime.now() + timedelta(seconds=timeout)
            while datetime.now() < stoptime:
                element = WebDriverWait(webdriver, WTF_TIMEOUT_MANAGER.BRIEF).until(
                    locator_lambda_expression)
                if element.is_displayed():
                    time.sleep(sleep)
                else:
                    break
        except TimeoutException:
            pass
开发者ID:AmyOrchid188,项目名称:wtframework,代码行数:28,代码来源:webelement.py

示例2: wait_until_element_not_visible

# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_displayed [as 别名]
 def wait_until_element_not_visible(webdriver, locator_lambda_expression, \
                                    timeout=WTF_TIMEOUT_MANAGER.NORMAL, sleep=0.5):
     "Wait for a WebElement to disappear."
     # Wait for loading progress indicator to go away.
     try:
         stoptime = datetime.now() + timedelta(seconds=timeout)
         while datetime.now() < stoptime:
             element = WebDriverWait(webdriver, WTF_TIMEOUT_MANAGER.BRIEF).until(locator_lambda_expression)
             if element.is_displayed():
                 time.sleep(sleep)
             else:
                 break
     except TimeoutException:
         pass
开发者ID:abaranova,项目名称:localway_tests,代码行数:16,代码来源:webelement.py

示例3: test_hello2

# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_displayed [as 别名]
    def test_hello2(self):
        # Navegamos hasta la aplicacion
        self.driver.get("http://the-internet.herokuapp.com/dynamic_loading/2")

        # Creamos el WebElement start
        self.start = self.driver.find_element_by_tag_name("button")

        # Hacemos click en Start
        self.start.click()

        finish = WebDriverWait(self.driver, 10)\
            .until(expected_conditions.visibility_of_element_located((By.ID, "finish")))

        # Capturamos todos los elementos que devuelve la busqueda
        self.assertTrue(finish.is_displayed(), "Hello world no fue encontrado!")
开发者ID:JosePabloOnVP,项目名称:IntroTestingAutomatizado,代码行数:17,代码来源:07b_explicit_wait.py

示例4: create_user

# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_displayed [as 别名]
    def create_user(self, name=None, emailAddr=None, role=None, isActive=None):     
        
        #local locators          
        _locCreateUser = (By.XPATH, "//child::section/a[text()='create a user']")        
        _locNewUserName = (By.XPATH, "//child::input[attribute::id='id_username']")
        _locNewUserEmail = (By.XPATH, "//child::input[attribute::id='id_email']")
        _locNewUserRole = (By.XPATH, "//child::select[attribute::id='id_groups']")
        _locNewUserStatus = (By.XPATH, "//child::input[@id='id_is_active']")  
        _locErrList = (By.XPATH, "//child::ul[attribute::class='errorlist']")               
        
        #[H] move to the user page
        self.__move_to_user_page()

        #create a new user
        #[H] click "create a user" tab
        try:
            element = WebDriverWait(self.selenium,self._TimeOut). \
                                    until(lambda s: self.find_element(*_locCreateUser))
        except Exceptions.TimeoutException:
            Assert.fail(Exceptions.TimeoutException)
        element.click()
            
        #[H] fill out the info of a new user
        try:
            elmntName = WebDriverWait(self.selenium,self._TimeOut). \
                                      until(lambda s: self.find_element(*_locNewUserName))
            elmntEmail = WebDriverWait(self.selenium,self._TimeOut). \
                                       until(lambda s: self.find_element(*_locNewUserEmail))
            elmntRole = WebDriverWait(self.selenium,self._TimeOut). \
                                      until(lambda s: self.find_element(*_locNewUserRole)) 
            elmntStatus = WebDriverWait(self.selenium,self._TimeOut). \
                                        until(lambda s: self.find_element(*_locNewUserStatus))                                                                                  
            elmntActions = WebDriverWait(self.selenium,self._TimeOut). \
                                         until(lambda s: self.find_element(*self._locAddUser))
            
            elmntName.send_keys(name)
            elmntEmail.send_keys(emailAddr)
            if isActive != None and isActive == 0:
                elmntStatus.click()     #set as an inactive user
                                                         
        except Exceptions.TimeoutException:
            Assert.fail(Exceptions.TimeoutException)
        try:
            Select(elmntRole).select_by_visible_text(role)
        except Exceptions.NoSuchElementException:
            Assert.fail(Exceptions.NoSuchElementException)
        elmntActions.click()   #submit the info
        
        #[M] check if the submission is complete without an error
        isErrListDisplayed = False
        try:
            elmntErrList = WebDriverWait(self.selenium,self._TimeOut). \
                                         until(lambda s: self.find_element(*_locErrList))
            isErrListDisplayed = elmntErrList.is_displayed()
        except Exceptions.TimeoutException:
            print "submission is complete without an error"
        if isErrListDisplayed == True:      
            print "the given set of the new user setting is already in use.\n"
            return False

        #[M] just check if the added user can be found in the DB
        element = self.__find_user(name, emailAddr, role)
        if element is None:
            return False
        else:
            return True
开发者ID:yoshiyokotani,项目名称:moztrap-tests,代码行数:68,代码来源:manage_user_page.py


注:本文中的selenium.webdriver.support.wait.WebDriverWait.is_displayed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。