question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when `switch_to.parent_frame` in PhantomJS and Safari

See original GitHub issue

Expected Behavior -

switch_to.parent_frame should switch to parent frame context

Actual Behavior -

#<Selenium::WebDriver::Error::WebDriverError: unexpected response, code=405, content-type="text/plain"
Invalid Command Method - {"headers":{"Accept":"application/json","Accept-Encoding":"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","Connection":"close","Content-Length":"2","Content-Type":"application/x-www-form-urlencoded","Host":"127.0.0.1:8910","User-Agent":"Ruby"},"httpVersion":"1.1","method":"POST","post":"{}","postRaw":"{}","url":"/frame/parent","urlParsed":{"anchor":"","query":"","file":"parent","directory":"/frame/","path":"/frame/parent","relative":"/frame/parent","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/frame/parent","queryKey":{},"chunks":["frame","parent"]},"urlOriginal":"/session/ffde7330-e150-11e5-93a8-5ded1f31d492/frame/parent"}>

Steps to reproduce -

@page.find_elements(:tag_name, "iframe").each do |iframe|
  @page.switch_to.frame(iframe)
  # eval some JS here
  @page.switch_to.parent_frame
rescue => e
  # error caught here
  @page.switch_to.default_content
end

Using selenium-webdriver ruby gem. Issue manifests under versions 2.52.0 and 2.46.2 (I was originally running 2.46.2, upgraded to 2.52.0 to try and resolve issue but still occurring)

Error occurs on PhantomJS 2.1.1. No errors with Firefox or Chrome. However Safari (latest driver: 2.48) reports a similar error:

#<Selenium::WebDriver::Error::UnknownError: Unknown command: switchToParentFrame>

FWIW, I get the exact same errors for PhantomJS/Safari when running under watir-webdriver 0.8.0, while watir+Firefox and watir+Chrome work fine.

On the other hand, Capybara works just fine on PhantomJS and Safari.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
franzejrcommented, Mar 26, 2016

I’m having the same problem on Safari. I have an iframe, when I go to my parentFrame, I got:

Selenium::WebDriver::Error::UnknownError:
       Unknown command: switchToParentFrame (WARNING: The server did not provide any stacktrace information)
       Command duration or timeout: 3 milliseconds
1reaction
lukeiscommented, Jun 14, 2016

switchTo defaultContent? then switch back down the frameset?

Read more comments on GitHub >

github_iconTop Results From Across the Web

not able to switch to iframe using phantomjs - Stack Overflow
Tried switching to frame using various locators such as index , id/name , webelement, no error encountered but objects of page are not...
Read more >
SafariDriver fails to switch to frames/iframes? Not currently ...
The below change in switching to iframe in Safari worked perfectly for me. driver.switchTo().frame(driver.findElement(By.id("frame_name")) ...
Read more >
Changes - Selenium
switchTo ().parentFrame(). When a named cookie is requested, attempt to fetch it directly using the W3C endpoint, GET /session/{session id}/cookie/{name} .
Read more >
Selenium WebDriver Commands | Pragmatic Test Labs
This may result in memory leak errors. ... You will have to switch to the parent frame if you would like to work...
Read more >
Agouti - Go Packages
Our PhantomJS integration test is a great place to see everything in action. Expand ▾ ... func (p *Page) SwitchToWindow(name string) error ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found