app自动化封装:自己写的小工具:等待机制

 def wait_10(self, xpath):
        exception=""
        try:
            while config.wait_Max_time - config.wait_time >= 0:
                time.sleep(config.wait_time)
                config.wait_Max_time = config.wait_Max_time - config.wait_time
                try:
                    wait_for = self.driver.find_element_by_xpath(xpath)
                    return wait_for
                except:
                    continue
        except Exception as e:
            exception=e
            raise Exception(exception)

使用说明:这是对xpath的封装:

     config.wait_Max_time最长等待时间

      config.wait_time 多久刷新一次

在config文件中设置,一般最长等待时间为5s,刷新时间为0.5秒。

 

 

 

你可能感兴趣的:(高级测试,初级测试)