RSelenium icon indicating copy to clipboard operation
RSelenium copied to clipboard

switch back to defaut frame

Open rafaleo opened this issue 7 years ago • 3 comments

In documentation is written:

switchToFrame(Id) Change focus to another frame on the page. Id can be string|number|null|WebElement Object. If the Id is null, the server should switch to the page’s default content.

So when I switch to some frame, do some operations and want to get back I use rdr$switchToFrame(NULL) I get message:

Selenium message:Missing 'id' parameter Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z' System info: host: 'MANIFOLD-4', ip: '192.168.184.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151' Driver info: driver.version: unknown

Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. class: org.openqa.selenium.WebDriverException Further Details: run errorDetails method

How to use it though? How to get default frame at the beginning to use it as an argument?

Executing objects I want to get now throws:

Selenium message:TypeError: can't access dead object Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z' System info: host: 'MANIFOLD-4', ip: '192.168.184.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151' Driver info: driver.version: unknown

Error : Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. class: org.openqa.selenium.WebDriverException Further Details: run errorDetails method

rafaleo avatar Nov 17 '17 12:11 rafaleo

same error occurred to me with chromedriver. looking for solution.

masterziedis avatar Nov 28 '17 21:11 masterziedis

I am having success with: remDr$switchToFrame(1)

mks212 avatar Mar 14 '18 16:03 mks212

Any support for this? Quite clearly isn't doing what is intended.

> driver$switchToFrame(NULL)

Selenium message:unknown error: missing 'id'
  (Session info: chrome=66.0.3359.117)
  (Driver info: chromedriver=2.38.551591 (XXX),platform=Linux 4.15.0-13-generic x86_64)

Error: 	 Summary: UnknownError
 	 Detail: An unknown server-side error occurred while processing the command.
	 Further Details: run errorDetails method

driver$switchToFrame(NA) seems to go through, however the context does not switch back.

@mks212 This fix does not work for me :(


EDIT: Actually it seems that it does work in general

library(RSelenium)

# driver = RSelenium::remoteDriver(browserName = "chrome")
driver = RSelenium::rsDriver(browser = "chrome", port = 6667L, verbose = FALSE)

# Dev only
URL = 'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe'
driver = driver$client
driver$open()
driver$navigate(URL)

# Quick way of testing if we've switch context
driver$getActiveElement()
>> 0.6427502624567305-2

iframe = driver$findElement("iframe", using = "tag name")
driver$switchToFrame(iframe$getElementAttribute("id")[[1]])
driver$getActiveElement()
>> 0.8892397525993796-2

driver$switchToFrame(NA)
driver$getActiveElement()
>> 0.6427502624567305-2

AkhilGNair avatar Apr 23 '18 17:04 AkhilGNair