首先,项目工作正常,最近我在办公室里安装了新电脑,我需要从头开始配置eclipse和selenium。所以我下载了新版本并尝试执行现有项目。然后我stat得到错误。 当我使用selenium独立服务器3.0.1 jar文件时,我收到以下错误
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 19354
Only local connections are allowed.
Jan 19, 2017 1:20:08 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Jan 19, 2017 1:20:08 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ilms.ILMSSmoke.ILMSSmoke.main(ILMSSmoke.java:49)
Caused by: org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'USARRVTANGUTUR4', ip: '172.19.113.118', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: cannot create temp dir for user data dir
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64), platform=ANY}]
Session ID: 5f757af2dcf474dd05d4edf93b323be5
*** Element info: {Using=link text, value=LOG OUT}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:425)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
at ilms.AmtrakTestDriver.AmtrakTestDriver.login(AmtrakTestDriver.java:13)
at ilms.ILMSSmoke.ILMSSmoke.editVacBid(ILMSSmoke.java:238)
... 5 more
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at org.apache.poi.util.TempFile$DefaultTempFileCreationStrategy.createTempFile(TempFile.java:105)
at org.apache.poi.util.TempFile.createTempFile(TempFile.java:60)
at org.apache.poi.openxml4j.opc.ZipPackage.closeImpl(ZipPackage.java:341)
at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:432)
at org.apache.poi.POIXMLDocument.close(POIXMLDocument.java:191)
at ilms.ILMSSmoke.ILMSSmoke.main(ILMSSmoke.java:80)
如果我使用Selenium server 2.53.0,则会显示以下错误
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 19354
Only local connections are allowed.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ilms.ILMSSmoke.ILMSSmoke.main(ILMSSmoke.java:49)
Caused by: java.lang.UnsatisfiedLinkError: Failed to create temporary file for /com/sun/jna/win32-x86-64/jnidispatch.dll library: Access is denied
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:776)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at org.openqa.selenium.os.Kernel32.<clinit>(Kernel32.java:34)
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:133)
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$2(UnixProcess.java:246)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:196)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:94)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:134)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at ilms.TestDriver.selectDriver(TestDriver.java:78)
at ilms.TestDriver.<init>(TestDriver.java:27)
at ilms.AmtrakTestDriver.AmtrakTestDriver.<init>(AmtrakTestDriver.java:9)
at ilms.schedule.Schedule.<init>(Schedule.java:13)
at ilms.ILMSSmoke.ILMSSmoke.editVacBid(ILMSSmoke.java:232)
... 5 more
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at org.apache.poi.util.TempFile$DefaultTempFileCreationStrategy.createTempFile(TempFile.java:105)
at org.apache.poi.util.TempFile.createTempFile(TempFile.java:60)
at org.apache.poi.openxml4j.opc.ZipPackage.closeImpl(ZipPackage.java:341)
at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:432)
at org.apache.poi.POIXMLDocument.close(POIXMLDocument.java:191)
at ilms.ILMSSmoke.ILMSSmoke.main(ILMSSmoke.java:80)
不确定我做错了什么。我尝试卸载chrome并按照ChromeWebDriver - unknown error: Chrome failed to start: crashed中的说明重新安装它。还是行不通。 任何帮助,将不胜感激 感谢
答案 0 :(得分:1)
基于以下错误消息:
java.io.IOException: The system cannot find the path specified
java.lang.UnsatisfiedLinkError: Failed to create temporary file for /com/sun/jna/win32-x86-64/jnidispatch.dll library: Access is denied
看起来Eclipse正在尝试创建临时文件,但不能。尝试使用提升的权限运行Eclipse(即以管理员身份运行),看看是否仍然收到相同的错误消息。
答案 1 :(得分:-1)
在做了一些研究后,我能够运行代码而没有错误。我做的解决方案是创建新的java类,并命名为旧类,后跟1.并将代码复制到新类。我在代码使用的地方使用了新的类名,并从项目包中删除了旧类。 对于Chromedriver.exe停止工作的问题,我发现在我的任务管理器中有多个chromedriver实例并结束了所有实例。这帮助我顺利进行。