1

I've been scraping a website using Selenium (Python Webdriver). When I try to have it click() an option, I get a permission denied error. Full stack trace:

Traceback (most recent call last): File "scrape.py", line 19, in <module> subjectOptions[1].click() File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 45, in click self._execute(Command.CLICK_ELEMENT) File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 194, in _execute return self._parent.execute(command, params) File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 153, in execute self.error_handler.check_response(response) File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 147, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: u"'Error: Permission denied for <http://localhost/scrape_test> to get property HTMLDocument.compatMode' when calling method: [wdIMouse::move]" 

Here is the code that causes the problem. I know for a fact that the option I'm trying to click exists (based on print):

from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait #available since 2.4.0 import time # Create a new instance of the FireFox driver driver = webdriver.Firefox() # go to the local version of the page for testing driver.get("http://localhost/scrape_test") # Find the select by ID, get its options selectElement = driver.find_element_by_id("CLASS_SRCH_WRK2_SUBJECT$65$") subjectOptions = selectElement.find_elements_by_tag_name("option") # Click the desired option subjectOptions[1].click() 

I'm using Firefox 8.0.1 on Mac OS X 10.7.2

3
  • 1
    What version of Firefox are you using, and on what OS? Commented Dec 20, 2011 at 19:59
  • What does subjectOptions[] hold? IF it is related to js, try adding a delay of 1-2sec before the click Commented Dec 20, 2011 at 20:13
  • subjectOptions[1] holds <selenium.webdriver.remote.webelement.WebElement object at 0x10eb6fb90> . subjectOptions is a list of such WebElements Commented Dec 20, 2011 at 20:15

2 Answers 2

5
+50

Looks like it's a webdriver bug. The latest log entry from the programmer who last modified one of the selenium source code files says:

This leads to permissions errors, which I've still been unable to reduce:

Error: Permission denied for http://www.finn.no to get property HTMLDocument.compatMode' when calling method: [wdIMouse::move]

There is some discussion about the issue here, here and here.

According to the discussion it should work fine with Firefox 7. Also, this related issue implies that the link is still clicked in spite of the error, so it might work inside a try/except.

Sign up to request clarification or add additional context in comments.

4 Comments

Putting a try catch didn't seem to resolve the issue for me. It goes past that part without exception but doesn't click them.
I did try: option.click() except: pass
Another solution would be to use an older build of Selenium. (I think 2.13.0 should not have the same problem.)
I settled on simply switching to another driver. Chrome and HTMLUNITWITHJS seem to do fine.
0

For time being you can overcome with work around given here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.