6

使用 Robot 框架和 Selenium2Library 处理 iframe 时遇到问题。它抛出错误:

WebDriverException: Message: unknown error: unhandled inspector error: {"code":-
32000,"message":"Cannot find context with specified id"}
(Session info: chrome=55.0.2883.87)
  (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)

我的测试代码是:

Fill In Description ${description}
    Wait Until Element Is Visible    ${FRAME}    40
    Select Frame    ${FRAME}
    wait until page contains element  ${IFRAME BODY}
    Click Element    ${IFRAME BODY}
    wait until page contains element  ${IFRAME BODY}
    Clear Element Text    ${IFRAME BODY}
    wait until page contains element  ${IFRAME BODY}
    Input Text    ${IFRAME BODY}     ${description}
    Unselect Frame

一步失败Input Text ${IFRAME BODY} ${description}

顺便说一句,我将此关键字用于出现此 iframe 的更多页面,但仅在一次确切的情况下失败 - 但所有 iframe 的 html 代码都是相同的,所以真的不明白为什么它有时会起作用..

会很高兴得到任何帮助。

4

2 回答 2

11

This issue seems to be reemerging in chromedriver, latest one being: https://bugs.chromium.org/p/chromedriver/issues/detail?id=2198

According to this ticket can be fixed in two ways:

  • switch to chromedriver version which does not have this issue
  • add wait after switching to frame
于 2018-01-08T11:21:05.947 回答
1

所以我不得不改变这样的代码在其他框架中工作:

Log comment ${comment}
   wait until element is visible    ${RICH TEXT AREA}    40
   sleep   1
   click element    ${RICH TEXT AREA}
   Wait Until Element Is Visible    ${FRAME}    40
   Select Frame    ${FRAME}
   wait until element is visible    ${IFRAME BODY}   20
   input text   ${IFRAME BODY}   ${comment}
   Unselect Frame

${IFRAME BODY}仍在//bodyIframe中,令人惊讶的是它现在一直在输入文本......不幸的是,没有睡眠它就无法工作:(但是有了睡眠它就可以工作..

于 2017-01-12T11:52:13.563 回答