File->Project Settings->Modules->Dependencies->'+'->JARS...
package com.smeoa.UI;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;
public class DemoChromeDriver
{
public static void main(String[] args) throws Exception
{
//设置浏览器的驱动属性、值。
System.setProperty("webdriver.chrome.driver","D:\\Driver\\chromedriver.exe");
//取消 chrome正受到自动测试软件的控制的信息栏
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
//实例化Driver对象
WebDriver driver = new ChromeDriver(options);
//打开网址:在url栏输入https://www.baidu.com
driver.get("http://www.baidu.com");
//xpath元素定位:输入栏,sendKeys输入Java
driver.findElement(By.xpath("/html//input[@id='kw']")).sendKeys("github");
//点击百度一下
driver.findElement(By.xpath("/html//input[@id='su']")).click();
Thread.sleep(100);
//关闭浏览器
driver.close();
}
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |