线程"main"中的异常org.openqa.selenium.NoSuchFrameException:在带有Centos 7的Docker中使用Selenium + Java + Chromedriver没有这样的框架 [英] Exception in thread "main" org.openqa.selenium.NoSuchFrameException: no such frame using Selenium + Java + Chromedriver in Docker with Centos 7

查看:105
本文介绍了线程"main"中的异常org.openqa.selenium.NoSuchFrameException:在带有Centos 7的Docker中使用Selenium + Java + Chromedriver没有这样的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Windows机器上执行的测试工作正常,但现在我试图使其在具有centos 7,java版本1.8.0_272,chrome和chromedriver 87.0的docker中工作,但它不起作用,这就是stacktrace说:

I have a test that executed in my windows machine works fine but now im trying to make it works in a docker with centos 7, java version 1.8.0_272, chrome and chromedriver 87.0 but it just dont works, this what the stacktrace says:

    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.pqrMovil.pqrMovilRegistrar(pqrMovil.java:30)行中,我的代码说:

driver.switchTo().frame(0);

我不知道它有多重要,但是,在期望成为硒信息的堆栈跟踪第12行中,只是未知"

I don't know how important it is, but, in the stacktrace line 12 where expect to be the selenium info there's just 'unknown'

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

As important information i can say that i import selenium-server-standalone.1.141.59.jar as a library in my test jar and again, i don't know if this is ok.

推荐答案

而不是使用 index 作为

< iframe> 中进行切换:

Instead of switching within the <iframe> using an index as:

driver.switchTo().frame(0);

理想情况下,您必须诱使定位器策略:

Ideally, you have to induce WebDriverWait for the frameToBeAvailableAndSwitchToIt() and you can use either of the following Locator Strategies:

  • 使用 frameName :

new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("frame_name")));

  • 切换 frameID :

    new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("frame_id")));
    

  • 使用 frameCssSelector :

    new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("frame_cssSelector")));
    

  • 使用 frameXpath :

    new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("frame_xpath")));
    

  • 您可以在以下位置找到一些相关的讨论:

    You can find a couple of relevant discussions in:

    这篇关于线程"main"中的异常org.openqa.selenium.NoSuchFrameException:在带有Centos 7的Docker中使用Selenium + Java + Chromedriver没有这样的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆