selenium 无法调用chrome driver 解决方案

下载适合的版本,并且eclipse中导入selenium的jar包后,启动chrome driver报错,unknown error: Runtime.executionContextCreated has invalid 'context':
或者chrome出现提示,您使用的是不受支持的命令行标记 需要在eclipse中对chrome进行处理,代码如下:
package test;

import java.util.Arrays;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

public class TestChromeDriver {
	public static void main(String[] args) {
		//也可以设置环境变量
		System.setProperty("webdriver.chrome.driver",
				"C:/Program Files (x86)/Google/chromedriver.exe");
		WebDriver webDriver = new ChromeDriver(capabilities);
		// webDriver.manage().window().maximize();
		webDriver.get("https://www.baidu.com");
		WebElement kw = webDriver.findElement(By.id("kw"));
		kw.sendKeys("APP");
		WebElement su = webDriver.findElement(By.id("su"));
		su.click();
		webDriver.close();
		System.out.println("Hello World!");
	}
}

你可能感兴趣的:(selenium)