webdriver-超时与等待
来源:互联网 发布:java中权限控制框架 编辑:程序博客网 时间:2024/06/05 09:30
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class selenium_timeout
{
//超时与等待,implicitlyWait,对象识别超时时间,pageLoadTimeout.页面加载超时时间
static WebDriver driver=new FirefoxDriver();
public static void main(String[] args) throws Exception
{
//全局设置,为代码中每个对象的识别设置超时时间
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//全局设置,为代码中每页面的加载设置超时时间
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.get("http://www.baidu.com/");//打开百度首页的超时时间为30秒
driver.findElement(By.id("kw")).sendKeys("selenium");//识别首页百度搜索框超时时间为30秒
driver.findElement(By.id("su")).click();//识别百度一下按钮的超时时间为30秒
selenium_timeout.openSetLink();
}
public static void openSetLink() throws Exception
{
//如果只为某单个对象的识别超时时间,则调用waitForTime方法
selenium_timeout.waitForTime(By.linkText("设置"));
driver.findElement(By.linkText("设置")).click();
}
//页面对象识别的超时时间方法
public static void waitForTime(By by) throws Exception{
for(int second=1;second<=30;second++)
{
try
{
driver.findElement(by);
break;
}
catch(Exception e)
{
e.printStackTrace();
}
}
Thread.sleep(1000);
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class selenium_timeout
{
//超时与等待,implicitlyWait,对象识别超时时间,pageLoadTimeout.页面加载超时时间
static WebDriver driver=new FirefoxDriver();
public static void main(String[] args) throws Exception
{
//全局设置,为代码中每个对象的识别设置超时时间
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//全局设置,为代码中每页面的加载设置超时时间
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.get("http://www.baidu.com/");//打开百度首页的超时时间为30秒
driver.findElement(By.id("kw")).sendKeys("selenium");//识别首页百度搜索框超时时间为30秒
driver.findElement(By.id("su")).click();//识别百度一下按钮的超时时间为30秒
selenium_timeout.openSetLink();
}
public static void openSetLink() throws Exception
{
//如果只为某单个对象的识别超时时间,则调用waitForTime方法
selenium_timeout.waitForTime(By.linkText("设置"));
driver.findElement(By.linkText("设置")).click();
}
//页面对象识别的超时时间方法
public static void waitForTime(By by) throws Exception{
for(int second=1;second<=30;second++)
{
try
{
driver.findElement(by);
break;
}
catch(Exception e)
{
e.printStackTrace();
}
}
Thread.sleep(1000);
}
}
0 0
- webdriver-超时与等待
- 超时与等待
- 非阻塞读终端与等待超时
- WebDriver等待事件
- WebDriver设置元素等待
- webdriver中的等待问题
- WebDriver的智能等待
- webdriver 等待方法
- WebDriver连接超时异常
- selenium webdriver超时设置
- WebDriver自定义显示等待条件
- selenium webdriver—超时设置
- CountDownLatch使用之等待超时
- 多线程之等待超时模式
- 等待超时实现简单方法
- watir-webdriver中的动态等待方法
- Selenium WebDriver等待页面元素加载完成
- WebDriver等待:Explicit and Implicit Waits
- 多平台轻量级消息推送系统msgd
- pfring 调研+总结
- spring框架学习(四)自动装配
- PHP获取微信粉丝的OpenID
- springMVC日期转换及The request sent by the client was syntactically incorrect.解决办法
- webdriver-超时与等待
- 简单编程题目连载(八)——最短路径问题
- 关于easyUI删除表格中的行后,提示删除成功并重新加载表格的方法
- Android程序员学PHP开发(13)-简易计算器-PhpStorm
- String...和String[]区别
- 数据库对象命名参考
- zoj1163
- Android StringUtils
- 程设作业(递归判断两个数互质)