我正在执行基本的硒测试。我尝试使用特定的配置文件,但是每次遇到相同的错误时,我都会尝试使用。
无论我注释还是取消注释代码以使用特定配置文件,我都会不断遇到相同的错误。我确保所有chrome实例均已关闭,但无济于事。
执行test时,它只是打开浏览器会话,但不加载URL。
代码:-
public class Main {
//static WebDriver driver;
public static void main(String[] args) throws AWTException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user_name\\chromedriver_win32\\chromedriver.exe");
//ChromeOptions options = new ChromeOptions();
//options.addArguments("user-data-dir=C:/Users/AppData/Local/Google/Chrome/User Data");
//options.addArguments("--start-maximized");
//options.addArguments("--profile-directory=Profile 2");
WebDriver driver = new ChromeDriver();
String URL = "http://www.google.com";
driver.get(URL);
错误:-
Starting ChromeDriver 75.0.3770.140 (2d9f97485c7b07dc18a74666574f19176731995c-refs/branch-heads/3770@{#1155}) on port 22065
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
我想运行测试:- 1>不使用特定配置文件 2>使用特定的配置文件
请告知我该怎么办。