Can not run any java script in Safari webdriver when the frame is empty
Selenium webdriver version: '2.47.1' os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_71' Safari version 7.1.7
Test to reproduce an issue.
WebDriver driver = createSafariDriver();
driver.get("http://localhost:8080/index.html");
WebElement iframe = driver.findElement(By.tagName("iframe"));
driver.switchTo().frame(0);
WebElement body = driver.findElement(By.tagName("body"));
((JavascriptExecutor) driver).executeScript("");
Simple HTML to run with test. (since the html tags are not visible see the attached picture)
Expected behavior. Do not throw any Exception
Here is the actual Exception
org.openqa.selenium.TimeoutException: Timed out awaiting response to command "executeScript" after 30002 ms (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 30.01 seconds Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44' System info: host: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_71' Session ID: null Driver info: Capabilities [{platform=MAC, cssSelectorsEnabled=true, javascriptEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.1.7}] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595) at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:504) at SafariTest.testExecuteScript(SafariTest.java:51)
This is a known issue first reported in https://code.google.com/p/selenium/issues/detail?id=7586
Safari does not properly initialize browser extensions for non-html pages.
One possible solution, should anyone want to take a stab at it, would be to fail any commands that target a non-html page and would result in the timeout reported above.
Closing this issue as there's nothing that can be done with the current driver.
Also, we will be dropping the current safaridriver when Safari 10 is released as it will include Apple's WebDriver implementation:
https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html