1

I'm trying to access a webpage using Selenium's webdriver, but no matter what browser I use (Opera/Firefox/GoogleChrome) I can't access the webpage.

In any of the cases, the browser pops-up and hangs there, does not access any URL.

When I try to run my script, I get

selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/bin/[opera/chrome] 

If I use firefox I get:

selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/firefox unexpectedly exited. Status code was: 0 

My code:

browser = webdriver.Firefox(executable_path=FIREFOX_PATH) browser.get('www.google.com') r = BeautifulSoup(browser.page_source, PARSER) print(r.text) 

I'm using Linux Ubuntu 18.04 with python3.6

1

1 Answer 1

1

Since you created the webdriver with executable_path=FIREFOX_PATH, I think you might have mixed up the keyword arguments for the paths to the Firefox binary and to the geckodriver binary. webdriver.Firefox expects:

  • firefox_binary – Instance of FirefoxBinary or full path to the Firefox binary. If undefined, the system default Firefox installation will be used.
  • executable_path – Full path to override which geckodriver binary to use for Firefox 47.0.1 and greater, which defaults to picking up the binary from the system path.

So for the Firefox binary firefox you need to set keyword argument firefox_binary. For geckodriver binary geckodriver you need to set keyword argument executable_path.


Do you even want/need to use other than the default binaries? Can you run

firefox --version 

and

geckodriver --version 

in your terminal without issues? Then you don't need to set firefox_binary or executable_path at all.

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

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.