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

08 January, 2014
I got the below error when I try to switch to iframe (driver.switchTo().frame("iframe_canvas"))

Permission denied for 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)


Looks like this happens because of Cross Origin. The solution to this problem is to change the settings of Firefox Profile in your code.


capability.policy.default.Window.QueryInterface='allAccess'  

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

I changed my code as below and it works 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 read:https://code.google.com/p/selenium/issues/detail?id=2863

No comments:

Post a Comment