Ben G
Ben G

Reputation: 26771

"Permission Denied" error ruins Selenium scraping

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

Upvotes: 1

Views: 4321

Answers (2)

Karthi
Karthi

Reputation: 479

For time being you can overcome with work around given here

Upvotes: 0

shamp00
shamp00

Reputation: 11326

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.

Upvotes: 5

Related Questions