SafariDriver fails to switch to frames/iframes? Not currently supported feature? Anyone encounter issues in this area?

2,649 views
Skip to first unread message

David

unread,
Aug 15, 2012, 9:50:42 PM8/15/12
to webdriver
I haven't found anything about this topic yet, nor in the issue
tracker, but came across the fact that one of the acceptance tests
dealing with window and frame switching is skipped for Safari:

http://selenium.googlecode.com/svn/trunk/dotnet/test/WebDriver.Common.Tests/WindowSwitchingTest.cs

Would like to confirm, does SafariDriver support switchin frames/
iframes? I can understand lack of support for window switching since
it can't handle alerts and can't open new window (via javascript). But
frames/iframes too?

Calling something like
driver.switchTo().frame(driver.findElements(By.tagName("iframe")).get(0));
can return timeout exception with message Timed out awaiting response
to command "switchToFrame" after 30002 ms

Calling driver.switchTo().frame(0); can return WebDriverException with
message 'undefined' is not an object (evaluating
'a.contentWindow.document')

I tried against different valid frames numbers (1, etc.) and it either
returned same errors or that it couldn't find element of next command
since it wasn't on the right frame.

I haven't seen the iframe switching issue in FF or IE so far.

darrell

unread,
Aug 16, 2012, 9:29:25 AM8/16/12
to webdriver
SafariDriver does not support frames. This was a big problem for me.
Approximately 45% of my customers are Safari/Mac users and my
application uses iframes quite heavily. :(

On Aug 15, 9:50 pm, David <manga...@gmail.com> wrote:
> I haven't found anything about this topic yet, nor in the issue
> tracker, but came across the fact that one of the acceptance tests
> dealing with window and frame switching is skipped for Safari:
>
> http://selenium.googlecode.com/svn/trunk/dotnet/test/WebDriver.Common...

David

unread,
Aug 17, 2012, 6:46:35 PM8/17/12
to webdriver
Thanks Darrell.

Is there a logged issue for that lack of support? Or it assume bundled
with the window open / alert issues?

Good to have a reference tracked in the issues list.

Sumit Saxena

unread,
Aug 18, 2012, 12:43:12 AM8/18/12
to webd...@googlegroups.com
Hi David you can use robot class for safari too

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


darrell

unread,
Aug 24, 2012, 8:21:25 AM8/24/12
to webd...@googlegroups.com
Hi David,

I don't know if there is a logged issue. The moment it came out I got it and the release notes for it. It was stated in the release notes that frames were not supported. I had plenty of work in other areas. So I put Safari on the back burner until I could put a dent in the other issues.

Darrell

Krishnan Mahadevan

unread,
Aug 24, 2012, 9:51:25 AM8/24/12
to webd...@googlegroups.com
David/Darrell,




3945 doesn't talk about switching to iframes, but it does state this : "If an iframe is removed from the DOM after the SafariDriver has focused on it, the driver will hang."

which makes me believe that perhaps iframes support is there in SafariDriver

Hope that helps !

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/bRGyRlwIHbMJ.

Pavithra

unread,
Aug 27, 2012, 7:51:53 AM8/27/12
to webd...@googlegroups.com
Switch to frame in safari driver works fine for me !!

--Pavithra

David

unread,
Sep 20, 2012, 2:12:42 AM9/20/12
to webd...@googlegroups.com
Thanks Krishnan.

Then I'm guessing support is there but usability is spotty and your mileage may vary. Just as with many cross-browser automation issues. :(

Simon Stewart

unread,
Sep 20, 2012, 7:14:42 AM9/20/12
to webd...@googlegroups.com
The SafariDriver has been written as a safari extension and uses (lots
of JS). We'd love some help improving it.

Simon
> https://groups.google.com/d/msg/webdriver/-/n7Vm1uYx1DMJ.

Siva

unread,
Apr 16, 2013, 7:19:45 AM4/16/13
to webd...@googlegroups.com
Hi Pavithra,

Can you tell me how it worked for you? Can you give us the steps to switch to frame in Safari -?

We are trying the below:
driver().switchTo().defaultContent();
driver().switchTo().frame("<iframe_name>");
driver().switchTo().activeElement();

But we got the error same as David mentioned.

Wrapped org.openqa.selenium.WebDriverException: 'undefined' is not an object (evaluating 'a.contentWindow.document')
(WARNING: The server did not provide any stacktrace information)

So whether Safari Driver really supports iframe? If so, just provide the steps.

Sumit Saxena

unread,
Apr 17, 2013, 5:31:08 AM4/17/13
to webdriver
Here we need to use robot class


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.

Test SCF

unread,
May 22, 2013, 2:26:08 AM5/22/13
to webd...@googlegroups.com
Thanks all for your suggestions. 

The below change in switching to iframe in Safari worked perfectly for me.

driver.switchTo().frame(driver.findElement(By.id("frame_name")));

Had to use driver findElement By Id for frame while switching - that is the reason it was throwing undefined.

Once it was switched - I was able to type into the text box as normal by selenium functions itself.

As Sumit suggested, we can use java.awt.Robot class also to type inside the iframe.


Teresa P

unread,
Aug 26, 2014, 9:00:39 AM8/26/14
to webd...@googlegroups.com
I'm having the same issue with Safari with the Python extension.  I'm on the latest version of selenium, the python library, as well as safari.  Has anyone had any luck about a workaround for this issue?  I've attempted using id's, index of the frame, the WebElement reference.... I'm running out of ideas!!

Help!

Thanks!

Xu Yang

unread,
Jan 19, 2015, 2:23:39 AM1/19/15
to webd...@googlegroups.com
Hi Siva,
 
I got such exception 'org.openqa.selenium.NoSuchElementException: could not find element' when using
dr.switchTo().frame(driver.findElement(By.id(IframeID)));
 Do you have any suggestion on it?
 

在 2013年5月22日星期三 UTC+8下午2:26:08,Siva写道:

Selenium Framework

unread,
Jan 20, 2015, 1:32:24 PM1/20/15
to webd...@googlegroups.com
Please see the below code. It executes fine and the driver is able to switch to the iframe and access an element inside the frame [The sleep was needed for synchronization as sometimes SafariDriver is taking time to connect on my machine]. Maybe I am just lucky to have it working [As David mentioned it might be spotty]

  1. Assuming you have all the jars, run the below class
  2. Selenium 2.44.0.jar , Safari Extension 2.38 [Safari - Preferences - Extensions]

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;


public class SimpleTest{

public static void main(String args[]) throws Exception
{
WebDriver driver = new SafariDriver();
driver.navigate().to("http://yourhtmlsource.com/frames/inlineframes.html");
Thread.sleep(5000);
WebElement frame = driver.findElement(By.name("bomb"));
System.out.println(frame.getAttribute("outerHTML"));
driver.switchTo().frame(driver.findElement(By.name("bomb")));
WebElement frame_body = driver.findElement(By.tagName("body"));
System.out.println(frame_body.getAttribute("outerHTML"));
driver.quit();
}
}

cheers
http://www.seleniumframework.com

Xu Yang

unread,
Jan 21, 2015, 4:56:09 AM1/21/15
to webd...@googlegroups.com
Thanks a lot for your help, I have successfully switched to the Iframe in Safari with the way you mentioned.

在 2015年1月21日星期三 UTC+8上午2:32:24,Selenium Framework写道:

Venkata Prasad Reddy

unread,
Apr 12, 2017, 2:20:56 AM4/12/17
to webdriver, sumit...@gmail.com
Hello Sumit,
 Could you please provide the sample robot code.

Thanks in advance
Reply all
Reply to author
Forward
0 new messages