selenium+ChromeDriver测试网站
配置:
1.chromdriver.exe
2.chrome.exe
3.selenium-server的jar包(我这里用的是selenium-server-4.1.4.jar)
导包过程
1.在项目处鼠标右键-》build path-》configure build path
2.如同所示
找到selenium的地址并导入
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class TestMain {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:/文档`在这里插入代码片`/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
// 设置chrome浏览器的 exe文件路径
options.setBinary("C:\\Users