1、依赖
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.14.0</version> </dependency>
2、Chrome驱动下载
找到浏览器版本对应的驱动 http://chromedriver.storage.googleapis.com/index.html
下载后解压,把chromedriver.exe文件放到项目根目录
3、简单示例,运行后能自动打开浏览器即成功了
package testcase; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; /** * @Description: * @ClassName: TestUi * @Author: whitewall * @Date: 2023/4/25 12:19 */ public class TestUi { @Test public void case1() { System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://www.baidu.com"); } }
标签:java,import,selenium,chromedriver,ui,自动化,org,driver From: https://www.cnblogs.com/whitewall/p/17352275.html