package test;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
public class Test1 {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
// D:\\driver是chromedriver服务地址
WebDriver driver = new ChromeDriver();
// 新建一个WebDriver 的对象,但是new 的是谷歌的驱动
String url = "http://www.baidu.com";
driver.get(url);
// 打开指定的网站
driver.findElement(By.id("kw")).sendKeys(new String[] { "setProperty" });
// 找到kw元素的id,然后输入hello
//打开百度F12

driver.findElement(By.id("su")).click(); // 点击按扭
//上述同样方法找到搜索按钮的ID
// driver.quit();// 退出浏览器
/**
* dr.quit()和dr.close()都可以退出浏览器,简单的说一下两者的区别:第一个close,
* 如果打开了多个页面是关不干净的,它只关闭当前的一个页面。第二个quit,
* 是退出了所有Webdriver所有的窗口,退的非常干净,所以推荐使用quit最为一个case退出的方法。
*/
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。