未处理的错误“找不到具有指定 id 的上下文"使用机器人框架 [英] Unhandled error "Cannot find context with specified id" using Robot framework

查看:23
本文介绍了未处理的错误“找不到具有指定 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..

很高兴得到任何帮助.

推荐答案

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

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 的上下文"使用机器人框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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