在selenium-grid上运行上传文件。说找不到文件。可是在本地确实没问题

这是我的代码
图片

报错信息
org.openqa.selenium.InvalidArgumentException: invalid argument: File not found : C:\Users\wanka\eclipse-workspace\ERP\testdata\256.png
(Session info: chrome=94.0.4606.54)
Build info: version: ‘3.6.0’, revision: ‘6fbf3ec767’, time: ‘2017-09-27T16:15:40.131Z’
System info: host: ‘DESKTOP-G7BBLLG’, ip: ‘172.16.21.102’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{networkConnectionEnabled=false, chrome={chromedriverVersion=94.0.4606.41 (333e85df3c9b656b518b5f1add5ff246365b6c24-refs/branch-heads/4606@{#845}), userDataDir=/tmp/.com.google.Chrome.oRINTn}, se:cdpVersion=94.0.4606.54, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, se:vnc=ws://172.18.0.4:5555/session/62d8c45759680f3880503a4686268a1f/se/vnc, platform=LINUX, se:cdp=ws://172.18.0.4:5555/session/62d8c45759680f3880503a4686268a1f/se/cdp, proxy=Proxy(), se:vncLocalAddress=ws://172.18.0.4:7900, goog:chromeOptions={debuggerAddress=localhost:37151}, webauthn:extension:credBlob=true, acceptInsecureCerts=false, browserVersion=94.0.4606.54, browserName=chrome, javascriptEnabled=true, platformName=LINUX, se:vncEnabled=true, setWindowRect=true, webauthn:extension:largeBlob=true, webauthn:virtualAuthenticators=true}]
Session ID: 62d8c45759680f3880503a4686268a1f
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
at page.PlanCreateHeTongPage.yingye(PlanCreateHeTongPage.java:542)
at business.PlanCreateHeTongBusiness.erpcreatehetong(PlanCreateHeTongBusiness.java:193)
at cases.ErpLoginNew2.erp_0001_hetong(ErpLoginNew2.java:278)
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

你的grid是在本地还是服务器上,你去这个路径下看看文件存在吗

是需要访问docker中的gird里面的文件吗?

那如果我用Jenkins执行呢。就调Jenkins中的文件还是gird中的呢?

他的流程是 code → grid hub → grid node → selneium,最终的selenium环境可能不具备你开发环境下的上下文数据。、你得确保你的最终执行机器上有文件,

几个可选的做法

  • 把文件的访问改成通过url下载
  • 通过jenkins把git也同步到selenium最终执行的节点上