My Thoughts: Permission denied for to get property Window.frameElement Command duration or timeout: 12 milliseconds

Tuesday, May 15

Permission denied for to get property Window.frameElement Command duration or timeout: 12 milliseconds

I used to get the below error when I try to switch to iframe ( driver.switchTo().frame("iframe_canvas") ).


Permission denied for <https://apps.facebook.com> to get property Window.frameElement Command duration or timeout: 12 milliseconds Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:09:00' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_23' Driver info: driver.version: RemoteWebDriver
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source)


Seems this issue is happening because of Cross Origin .
Solution to this problem is set the below settings in Firefox Profile.
capability.policy.default.Window.QueryInterface='allAccess'

capability.policy.default.Window.frameElement.get='allAccess'

I changed my code as below. Now it is working fine :)
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
 
public void IframeTest(){

 WebDriver driver;

@BeforeTest
  public void setUpDriver() {
   FirefoxProfile profile = new FirefoxProfile();
   profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess");
   profile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");
   driver = new FirefoxDriver(profile);
     }

@Test
 public void delete(){
   Common.FBLogin(fbUsername, fbPassword, driver);
   driver.get("appURL");
   driver.switchTo().defaultContent();
   driver.switchTo().frame("iframe_canvas");  
  }

}
For more details check this one  :
http://code.google.com/p/selenium/issues/detail?id=2863


If you ever happened to get the above error then change your Firefox preferences from code :)


1 comment:

  1. Thanks. The recommended solution in this blog did not work for me in Firefox 14.

    Below did:
    driver.switchTo().frame(driver.findElement(By.id("my-frame-id")));

    ReplyDelete