Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhandled error "Cannot find context with specified id" using Robot framework

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)

My test code is:

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

It fails in step Input Text ${IFRAME BODY} ${description}

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.

like image 622
neliCZka Avatar asked Jan 02 '17 15:01

neliCZka


2 Answers

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
like image 65
James Windshield Avatar answered Oct 22 '22 13:10

James Windshield


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} 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..

like image 1
neliCZka Avatar answered Oct 22 '22 11:10

neliCZka