Issue 1371 in selenium: SwitchTo Support in the iPhone Driver

44 views
Skip to first unread message

sele...@googlecode.com

unread,
Mar 7, 2011, 7:31:10 PM3/7/11
to selenium-deve...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1371 by petern...@gmail.com: SwitchTo Support in the iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

What steps will reproduce the problem?
1. Check out the latest stable build from
http://selenium.googlecode.com/svn/trunk/
2. Setup/Build the iPhoneDriver from iphone/iWebDriver.xcodeproj
3. Run a Debug copy of the iPhoneDriver in a simulator
4. Create a new selenium test case
5. Connect to the iPhoneDriver with a RemoteWebDriver()
6. Navigate to a page that contains iframes
7. Find all elements with tag name "iframe"
8. For each found element do driver.switchTo().frame(webElement) and then
attempt to do driver.getCurrentUrl() to make sure that you've changed to
the new frame context


What is the expected output? What do you see instead?
switchTo should work as it does in other drivers, instead this call stack
is returned when the call to .frame(webElement) is done:
java.lang.UnsupportedOperationException: <html><body>Error 404 - Not
Found</body></html>
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:131)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:105)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:410)
at
org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:570)
at BarFoo.GoodiesTest(BarFoo.java:105)


What version of the product are you using? On what operating system?
Should be the latest everything, i386 version on an iPhone 4 simulator,
running iOS 4.2

Please provide any additional information below.

Source code for a test case:
// Connect to the iPhoneDriver
WebDriver driver = new RemoteWebDriver(new
URL("http://0.0.0.0/hub"), new DesiredCapabilities());

// Go the the html goodies page on inline frames

driver.get("http://www.htmlgoodies.com/tutorials/frames/article.php/3479271");

// Grab all of the iframe elements on the page
List<WebElement> iframes =
driver.findElements(By.tagName("iframe"));

// Print out all of the urls that the different iframes point to
int position = 0;
for(WebElement we : iframes){
System.out.println(position++ + ". Url:" +
we.getAttribute("src"));
}
// The url should be the same as the html goodies' article since we
haven't done a switch yet.
System.out.println(driver.getCurrentUrl());

// Grab the index '1' element which should be the first example
iframe from this page
driver.switchTo().frame(iframes.get(1));

// After we've switch to the frame, print out the current url so
that it can be verified to have changed.
System.out.println(driver.getCurrentUrl());


sele...@googlecode.com

unread,
Mar 8, 2011, 4:40:03 PM3/8/11
to selenium-deve...@googlegroups.com

Comment #1 on issue 1371 by haidhar...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

frame and window switching isn't supported/implemented in iPhone yet.

sele...@googlecode.com

unread,
Mar 9, 2011, 8:15:34 PM3/9/11
to selenium-deve...@googlegroups.com
Updates:
Labels: -Type-Defect Type-Enhancement Browser-IPhone

Comment #2 on issue 1371 by jmleyba: SwitchTo Support in the iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

(No comment was entered for this change.)

sele...@googlecode.com

unread,
Aug 18, 2011, 8:17:42 AM8/18/11
to selenium-deve...@googlegroups.com

Comment #3 on issue 1371 by iuli...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Anyone found any workaround?

sele...@googlecode.com

unread,
Oct 20, 2011, 7:08:49 AM10/20/11
to selenium-deve...@googlegroups.com
Updates:
Status: Accepted
Cc: jml...@gmail.com
Labels: BuildingBlock

Comment #5 on issue 1371 by jari.bakken: SwitchTo Support in the iPhone
Driver
http://code.google.com/p/selenium/issues/detail?id=1371

This issue prevents any use of the iPhone driver with watir-webdriver,
since we do a lot of extra switch_to.default_content calls to get Watir's
Browser#frame semantics on top of WebDriver.

sele...@googlecode.com

unread,
Nov 21, 2011, 5:19:23 PM11/21/11
to selenium-deve...@googlegroups.com

Comment #6 on issue 1371 by jari.bakken: SwitchTo Support in the iPhone
Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Issue 2868 has been merged into this issue.

sele...@googlecode.com

unread,
Nov 21, 2011, 5:27:29 PM11/21/11
to selenium-deve...@googlegroups.com

Comment #7 on issue 1371 by tarek...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

The provided patch allows for support for iframes that have the same
document.domain as the parent page. This will support the
/session/:sessionId/frame command in iWebDriver to be able to handle
multiple frames. Supporting iframes on different domains appears difficult
on iOS webviews without requiring the iframe page to load some custom JS
code.

(This is the patch that was attached to Issue 2868)

Attachments:
frame.patch 2.9 KB

sele...@googlecode.com

unread,
Nov 24, 2011, 12:06:57 PM11/24/11
to selenium-deve...@googlegroups.com

Comment #8 on issue 1371 by jml...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

@tarekfah Unfortunately, your patch doesn't adhere to the defined behavior
for frame switching in the JsonWireProtocol (as I write this, I realize the
protocol is actually out of date...)

The ID sent with POST /session/:sessionId/frame could be:

* null - Switch to window.top

* a string - Switch to the frame whose name or ID matches the string. Since
name is a standard frame property, give preference to name matches over ID.

* a number - Switch to the frame at the given index in window.frames

* A WebElement reference (eg, {"ELEMENT":"foo"}) -
** Check that the WebElement reference is not stale
** Check that the WebElement is for an iframe or frame
** Switch to the frame element's content window

Here's the handler for Firefox's switchToFrame:
http://code.google.com/p/selenium/source/browse/trunk/javascript/firefox-driver/extension/components/firefoxDriver.js#557

Other than that, your patch does have the basic approach: track the frame
that scripts should be executed in, and eval in its context.

sele...@googlecode.com

unread,
Dec 16, 2011, 8:33:04 AM12/16/11
to selenium-deve...@googlegroups.com

Comment #9 on issue 1371 by saritapo...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Facing the same issue even after applying the patch.
The configuration is Mac OSX 10.6.8 and ipad Simulator IOS 4.2

Please let me know if there is any other work around for Switch To


sele...@googlecode.com

unread,
Jan 13, 2012, 12:16:27 PM1/13/12
to selenium-deve...@googlegroups.com
Updates:
Owner: luke.sem...@gmail.com

Comment #10 on issue 1371 by luke.sem...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Started working on this, first pass looks like it won't support cross
domain frames.

sele...@googlecode.com

unread,
Jan 21, 2012, 12:37:05 AM1/21/12
to selenium-deve...@googlegroups.com
Updates:
Cc: jari.bakken

Comment #11 on issue 1371 by jari.bakken: SwitchTo Support in the iPhone
Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Luke: I'm interested in making this work. Anything I can do to help?

sele...@googlecode.com

unread,
Jan 21, 2012, 2:17:01 PM1/21/12
to selenium-deve...@googlegroups.com

Comment #12 on issue 1371 by luke.sem...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

Thanks Jari, I've got it mostly working. And am just running through some
test cases. Should have it checked in sometime this week.

So, I couldn't find any hooks to directly execute JS in a frame so cross
domain will definitely not work for iPhone with the changes I'm making.

sele...@googlecode.com

unread,
Jan 22, 2012, 8:09:33 AM1/22/12
to selenium-deve...@googlegroups.com

Comment #13 on issue 1371 by jari.bakken: SwitchTo Support in the iPhone
Driver
http://code.google.com/p/selenium/issues/detail?id=1371

OK, looking forward to the commit :)

sele...@googlecode.com

unread,
Jan 25, 2012, 3:01:56 PM1/25/12
to selenium-deve...@googlegroups.com
Updates:
Status: Fixed

Comment #14 on issue 1371 by luke.sem...@gmail.com: SwitchTo Support in the
iPhone Driver
http://code.google.com/p/selenium/issues/detail?id=1371

This issue was closed by revision r15656.

Reply all
Reply to author
Forward
0 new messages