6

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.

neliCZka
  • 945
  • 1
  • 16
  • 27
  • what does `${IFRAME BODY}` represent? By the name it sounds like an iframe element or the body inside an iframe, in which case I don't understand why you're trying to input text into an iframe (versus an input element). – Bryan Oakley Jan 02 '17 at 15:53
  • The structure in html is: and the element is the one which stands for "input field", there is no other element inside..thats why I am trying to input into element...and as I mentioned, it works in 2 cases, but does not work in 1 case... – neliCZka Jan 02 '17 at 15:56
  • 1
    what do you think should happen when you input text into something that isn't designed to take text? – Bryan Oakley Jan 02 '17 at 16:18
  • well, obviously it types the text into the body element - really works for 2 out of my 3 cases (pages with iframes)...just in one it does not, and I really don't know why because the code behind that is the same.. – neliCZka Jan 02 '17 at 16:30
  • I just had the same error message on a test script. The exception is thrown on this line: `WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,myxpath)))` Similar to what @neliCZka is reporting, it sometimes hangs on this line, which is re-iterated several times, but most other times, it works fine. I wish I knew how this error is different than, say, an "element not found" error or a "timeout" error. – Suzanne Jan 04 '17 at 01:21
  • Are you seeing the same problem when using a different browser? Just to narrow the search for the solution? – A. Kootstra Jan 08 '17 at 07:37
  • I'm pretty sure this error message is being [generated by Chrome](https://github.com/Microsoft/vscode/issues/20820) instead of Selenium or Robot. I'm having the same problem with puppeteer + Chrome, so a generic, non-Selenium answer would be nice. – jpaugh Jan 06 '18 at 00:05

2 Answers2

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
jpaugh
  • 6,634
  • 4
  • 38
  • 90
1

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

jpaugh
  • 6,634
  • 4
  • 38
  • 90
neliCZka
  • 945
  • 1
  • 16
  • 27
  • What change did you make? I'm getting the same error message with [puppeteer](https://github.com/GoogleChrome/puppeteer) against Chrome, but I this code is a wall of text to me. Thanks! – jpaugh Jan 06 '18 at 00:01
  • 1
    I dont know really, I just added implicit wait (sleep) and I did some clicking into the element in which the iframe exists before I access the iframe itself. It is also possible that it started working due to higher version of chrome driver. – neliCZka Jan 08 '18 at 09:11