无法找到具有指定ID的上下文

无法找到具有指定ID的上下文

本文介绍了未处理的错误“无法找到具有指定ID的上下文"使用机器人框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Robot框架和Selenium2Library处理iframe时出现问题.它引发错误:

I have a problem when working with iframe using Robot framework and Selenium2Library. It throws error:

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代码都是相同的,所以真的不明白为什么它有时会起作用.

Btw I reuse this keyword for more pages where this iframe occurs but it fails only in once exact case - but the html code is the same for all the iframes, so really dont understand why it works just sometimes..

将很高兴获得任何帮助.

Will be glad for any help.

推荐答案

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

So I had to change the code like this to work in other frame:

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}在iframe中仍然是//body,令人惊讶的是,它现在一直在输入文本...而且不幸的是,没有睡眠它是无法工作的:(但是,有了睡眠它就可以工作..

${IFRAME BODY} is still //body in Iframe and surprisingly it inputs the text all the time now...And unfortunately it does not work without sleep :( But with sleep it works..

这篇关于未处理的错误“无法找到具有指定ID的上下文"使用机器人框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 03:54