Search This Blog

Thursday, February 16, 2012

Handling Permission denied error for error using Seleium WebDriver

Depending on the application page structure you may encounter with below error sometimes on FF (may be other browsers) latest versions while trying to clicking on any element, and there is no consistent resolution from Selenium Team yet, and we need to live with some work around for this.

  1. Error: Permission denied for <> to get property HTMLDocument.compatMode' when calling method: [wdIMouse::move]" 
  2. Error: Permission denied for <> to get property Location.href [error] Permission denied for <> to get property Location.href 
  3. WebDriverException: Message: u'Permission denied for <> to get property Window.mozInnerScreenX'
  4. Exception thrown org.openqa.selenium.WebDriverException: Permission denied for <> to get property Window.frameElement;

  1. First one works sometimes but may not all the times. Just wrap your click statement in try/catch block in spite of the error, element will be clicked successfully.
  2. Using JavaScript executor you can click on such elements using below code.
String windowHandle=driver.getWindowHandle(); //driver is webdriver object here
WebElement element = driver.findElement(By.xpath(xpath));
Actions builder = new Actions(driver);   
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("var evt = document.createEvent('MouseEvents');""evt.initMouseEvent('click',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);""arguments[0].dispatchEvent(evt);", element);
driver.switchTo().window( windowHandle );  


  1. I know this is 7 months old, however, I was having this issue with and the easier work-around i've found was doing this:

    WebElement submitButton = driver.findElement(By.className("btn-primary"));


  2. Excellent Post. Also visit

  3. Fantastic article ! You havemade some very astute statements and I appreciate the the effort you have put into your writing. Its clear that you know what you are writing about. I am excited to read more of your sites content.

    Big data online training

  4. Hey very nice blog!!
    Hi there,I enjoy reading through your article post, I wanted to write a little comment to support you and wish you a good continuationAll the best for all your blogging efforts.
    Appreciate the recommendation! Let me try it out.
    Keep working ,great job!
    Hadoop training

  5. Hi
    I read this post two times.
    I like it so much, please try to keep posting.
    Let me introduce other material that may be good for our community.

    Microsoft dynamics training

  6. je.executeScript("function detectLink1(){ var anchor = document.getElementsByTagName('"+tag+"');var a; for(i=0;i<anchor.length;i++){if ((anchor[i].innerHTML).indexOf('"+searchText+"') != -1) {a=anchor[i];break;}};}detectLink1();");

    is not clicking the element, can anyone help?