“线程中的异常”;“主要”;org.openqa.selenium.NoSuchFrameException:没有使用selenium+;Java+;Chromedriver在Docker与Centos 7

“线程中的异常”;“主要”;org.openqa.selenium.NoSuchFrameException:没有使用selenium+;Java+;Chromedriver在Docker与Centos 7,java,linux,docker,selenium,centos7,Java,Linux,Docker,Selenium,Centos7,我有一个在我的windows机器上执行的测试工作正常,但现在我正试图让它在centos 7、java版本1.8.0Đ272、chrome和chromedriver 87.0的docker中工作,但它就是不工作,stacktrace说: Starting ChromeDriver 87.0.4280.20 (c99e81631faa0b2a448e658c0dbd8311fb04ddbd-refs/branch-heads/4280@{#355}) on port 23699 All re

我有一个在我的windows机器上执行的测试工作正常,但现在我正试图让它在centos 7、java版本1.8.0Đ272、chrome和chromedriver 87.0的docker中工作,但它就是不工作,stacktrace说:

    Starting ChromeDriver 87.0.4280.20 (c99e81631faa0b2a448e658c0dbd8311fb04ddbd-refs/branch-heads/4280@{#355}) on port 23699
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[main] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Starting proxy at address: 0.0.0.0/0.0.0.0:0
[main] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy listening with TCP transport
[main] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy started at address: /0.0.0.0:34162
Nov 30, 2020 2:12:27 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.NoSuchFrameException: no such frame
  (Session info: headless chrome=87.0.4280.66)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'b3782858cd26', ip: 'xxx.xx.x.x', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1127.el7.x86_64', java.version: '1.8.0_272'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.66, chrome: {chromedriverVersion: 87.0.4280.20 (c99e81631faa0..., userDataDir: /tmp/.com.google.Chrome.Tp1C2S}, goog:chromeOptions: {debuggerAddress: localhost:39255}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(manual, http=proxy.cl..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 8b9b8ef4dd9b0e870d8974c6f3b38e47
        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:187)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
        at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:872)
        at seleniumjavapqr.pqrMovil.pqrMovilRegistrar(pqrMovil.java:30)
        at seleniumjavapqr.myDriver.main(myDriver.java:128)
[LittleProxy-JVM-shutdown-hook] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Shutting down proxy server immediately (non-graceful)
[LittleProxy-JVM-shutdown-hook] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Closing all channels (non-graceful)
[LittleProxy-JVM-shutdown-hook] INFO org.littleshoot.proxy.impl.ServerGroup - Shutting down server group event loops (non-graceful)
[LittleProxy-JVM-shutdown-hook] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Done shutting down proxy server
在seleniumjavapqr.pqrmovill.pqrmovillregister(pqrmovill.java:30)行中我的代码说:

driver.switchTo().frame(0);
我不知道这有多重要,但在stacktrace第12行中,预期是selenium信息,这里只是“未知”


作为重要信息,我可以说我将selenium-server-standalone.1.141.59.jar作为库导入到我的测试jar中,我不知道这是否正确。

而不是使用索引在
中切换:

理想情况下,您必须将
框架归纳为可用和switchtoit()
,并且可以使用以下任一选项:

  • 使用frameName:

  • 交换机帧ID:

  • 使用FrameCsSelector:

  • 使用frameXpath:


参考文献 您可以在以下内容中找到一些相关讨论:


是的,我做到了。我有一个在docker中运行的应用程序,通过chrome驱动程序获取数据。您使用的是哪种基本图像?我使用了这个:从markhobson/maven chrome:jdk-11I从centos:7开始使用,在安装chrome和java的内部,我将尝试使用以下命令在容器中启动jar:if[-z“$BROKERHOST”];然后BROKERHOST=
ip路由| grep默认| cut-d'-f3
;echo“[I]未设置BROKERHOST。已确定:$BROKERHOST”;fi;brokerUrl=“tcp://${BROKERHOST}:${BROKERPORT:-61616}”;java-jar-Dspring.activemq.broker url=${brokerrurl}-Dwebdriver.chrome.driver=/usr/bin/chromedriver YOURJAR.jar
172.17.0.1[I]未设置BROKERHOST。确定:
这就是答案,你使用了我建议的相同图像(markhobson/maven chrome:jdk-11)?如果您使用docker run-it image/bin/sh启动映像,然后键入ip路由,会发生什么情况?您正在使用哪种网络模式?
driver.switchTo().frame(0);
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("frame_name")));
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("frame_id")));
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("frame_cssSelector")));
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("frame_xpath")));