本文共 2178 字,大约阅读时间需要 7 分钟。
免费的分布式的自动化测试工具
多平台支持:windows、linux、MAC
多浏览器支持:ie、ff、safari、opera、chrome
多语言支持:C、 java、ruby、python、C#
WebDriver是一个开源工具,可用于跨多种浏览器自动测试Web应用程序。它提供了导航到网页,用户输入,JavaScript执行等功能。ChromeDriver是一个独立的服务器,它实现 了 。ChromeDriver可用于Android上的Chrome和台式机(Mac,Linux,Windows和ChromeOS)上的Chrome。
- Google Chrome 浏览器
- JDK 1.8+
Selenium:
ChromeDriver:
Google Chrome:
Chrome 命令行参数:
XPath:
Java 正则表达式:
Jsoup官网:
资源下载:
资源下载:
org.seleniumhq.selenium selenium-java 3.141.59
“–disable-gpu”:不使用 GPU 加速
“–headless”:启动 chrome 的 headless 模式,即不会弹出浏览器界面
import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.chrome.ChromeOptions;import java.io.IOException;public class Bing { public static void main(String[] args) throws IOException { // chromedriver 解压路径 String chromeDriverFilePath = "C:/chromedriver_win32/chromedriver.exe"; // 配置环境变量 System.getProperties().setProperty("webdriver.chrome.driver" , chromeDriverFilePath); // 设置浏览器选项 ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--disable-gpu", "--headless"); WebDriver webDriver = new ChromeDriver(chromeOptions); webDriver.get("https://www.bing.com"); String content = webDriver.getPageSource(); webDriver.close(); // 输出内容 System.out.println(content); }}
org.seleniumhq.selenium selenium-java 3.141.59 org.seleniumhq.selenium selenium-remote-driver 3.141.59 org.seleniumhq.selenium selenium-api 3.141.59 org.seleniumhq.selenium selenium-chrome-driver 3.141.59 org.seleniumhq.selenium selenium-support 3.141.59
转载地址:http://rwnws.baihongyu.com/