lesson1基础登陆
来源:互联网 发布:cod7低配优化补丁 编辑:程序博客网 时间:2024/06/08 10:14
package ccwp;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
public class lesson1 {
/**
* @param args
*/
public class ExampleForFireFox {
public void main(String[] args) {
// 如果你的 FireFox 没有安装在默认目录,那么必须在程序中设置
// System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
// 创建一个 FireFox 的浏览器实例
WebDriver driver = new FirefoxDriver();
// 让浏览器访问 Baidu
//driver.get("http://www.baidu.com");
// 用下面代码也可以实现
driver.navigate().to("http://www.baidu.com");
// 获取 网页的 title
System.out.println("1 Page title is: " + driver.getTitle());
// 通过 id 找到 input 的 DOM
WebElement element = driver.findElement(By.id("kw"));
// 输入关键字
element.sendKeys("zTree");
// 提交 input 所在的 form
element.submit();
// 通过判断 title 内容等待搜索页面加载完毕,间隔10秒
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().endsWith("ztree");
}
});
// 显示搜索结果页面的 title
System.out.println("2 Page title is: " + driver.getTitle());
//关闭浏览器
driver.quit();
}
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
public class lesson1 {
/**
* @param args
*/
public class ExampleForFireFox {
public void main(String[] args) {
// 如果你的 FireFox 没有安装在默认目录,那么必须在程序中设置
// System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
// 创建一个 FireFox 的浏览器实例
WebDriver driver = new FirefoxDriver();
// 让浏览器访问 Baidu
//driver.get("http://www.baidu.com");
// 用下面代码也可以实现
driver.navigate().to("http://www.baidu.com");
// 获取 网页的 title
System.out.println("1 Page title is: " + driver.getTitle());
// 通过 id 找到 input 的 DOM
WebElement element = driver.findElement(By.id("kw"));
// 输入关键字
element.sendKeys("zTree");
// 提交 input 所在的 form
element.submit();
// 通过判断 title 内容等待搜索页面加载完毕,间隔10秒
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().endsWith("ztree");
}
});
// 显示搜索结果页面的 title
System.out.println("2 Page title is: " + driver.getTitle());
//关闭浏览器
driver.quit();
}
}
}
0 0
- lesson1基础登陆
- lesson1
- lesson1
- lesson1
- Lesson1
- lesson1
- Ubuntu学习日记--Lesson1:Linux基础和常用命令
- 【安卓学习笔记】JAVA基础Lesson1-简介与变量
- LogicJava---Lesson1
- lesson1作业
- java lesson1
- Opencv lesson1
- Swift-Lesson1
- WIN32 lesson1
- SWift Lesson1
- JS Lesson1
- Python lesson1
- h5-lesson1
- mybatis配置使用多个数据源
- OpenCv调整图片(Mat)大小
- Check_code_five
- 采购订单通过open interface导入
- 【Java】Java中GUI之布局管理器
- lesson1基础登陆
- Windows系统下Apache性能优化,提高并发
- Linux workqueue工作原理
- Android 布局文件XML编写注意项
- zookeeper基本原理及适用场景
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
- SqlServer---RowCount 和 @@RowCount的用法和区别
- redis环境搭建——介绍、安装、配置
- spring集成dubbo的配置文件