运行以下代码时,我收到以下错误。这段代码适用于Selenium 2.53.1 浏览器详细信息:
Chrome - Version 59.0.3071.115 (64-bit)
Chrome driver - 2.30
下面的代码与普通的Java项目完美配合。仅面对Maven项目的问题。
public class TestSel {
public static void main(String[] args) {
System.setProperty("WebDriver.chrome.driver", "chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://gmail.com");
driver.manage().window().maximize();
System.out.println("Testing Complete");
}
}
错误日志:
Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 21042
Only local connections are allowed.
Jul 03, 2017 1:57:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: java.nio.file.FileSystemException: C:\Users\vijender\AppData\Local\Temp\new-session2428533575725549690.json: The process cannot access the file because it is being used by another process.
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'LC-VIJENDERC', ip: '192.168.6.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at rough.TestSel.main(TestSel.java:10)
Caused by: java.nio.file.FileSystemException: C:\Users\vijender\AppData\Local\Temp\new-session2428533575725549690.json: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
at java.nio.file.Files.deleteIfExists(Files.java:1165)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:168)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 8 more
答案 0 :(得分:0)
问题是我的系统特定。由窗口重置决定。