• implicitly_wait()隐式等待


    # -*- coding:utf-8 -*-
    
    """
    implicitly_wait():隐式等待
    当使用了隐士等待执行测试的时候,如果 WebDriver没有在 DOM中找到元素,将继续等待,超出设定时间后则抛出找不到元素的异常
    换句话说,当查找元素或元素并没有立即出现的时候,隐式等待将等待一段时间再查找 DOM,默认的时间是0
    一旦设置了隐式等待,则它存在整个 WebDriver 对象实例的声明周期中,隐式的等到会让一个正常响应的应用的测试变慢,
    它将会在寻找每个元素的时候都进行等待,这样会增加整个测试执行的时间。
    """
    
    from selenium import webdriver 
    import time
    
    driver = webdriver.Firefox()
    driver.get('http://demo.tutorialzine.com/2009/09/simple-ajax-website-jquery/demo.html')
    
    #等待10秒
    driver.implicitly_wait(10)
    driver.find_element_by_link_text("Page 4").click()
    
    message = driver.find_element_by_id('pageContent')
    #等待 Ajax 的内容出现
    time.sleep(4)
    print "Nunc nibh tortor" in message.text
  • 相关阅读:
    python
    python
    python
    Django学习手册
    python
    Django学习手册
    [ThinkPHP] 独立分组配置,坑!!!
    vim 代码片段:通过vundle插件管理器安装ultisnips |centos6.5|vim7.2
    CESHI
    thinkphp实现功能:验证码
  • 原文地址:https://www.cnblogs.com/hankleo/p/10780940.html
Copyright © 2020-2023  润新知