zoukankan      html  css  js  c++  java
  • Selenium2设置隐式等待和显示等待

    1. 设置显示等待

    Java代码:

    public static WebElement WaitForElement(WebDriver driver, String locator)
        {
    		WebElement targetElement = (new WebDriverWait(driver,10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath(locator)));
    		return targetElement;	
    	}
    

      

    1 WebDriver driver = new FirefoxDriver(); driver.get("http://somedomain/url_that_delays_loading"); 
    2 WebElement myDynamicElement = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicElement"))); 
    View Code

    2. 设置隐式等待

    Java代码:

    WebDriver driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get("http://i8xiaoshi.com");
    WebElement myDynamicElement = driver.findElement(By.id("xxxx"));
    

     

    1 WebDriver driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://somedomain/url_that_delays_loading"); 
    2 WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement")); 
    View Code
  • 相关阅读:
    如何从ORACLE数据库生成HBM和JAVA
    timer
    工作流研究
    linux date命令设置时间
    耶基斯多得森曲线
    朋友考我的一个基础语法题
    微软企业库(一)
    标记属性
    Word自动化撤销、重做功能
    汇编中的ASSUME
  • 原文地址:https://www.cnblogs.com/shinhwa/p/3688184.html
Copyright © 2011-2022 走看看