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

finefoot
  • 9,914
  • 7
  • 59
  • 102
SnuKies
  • 1,578
  • 1
  • 16
  • 37
  • You didn't set up path to Geckodriver. Please take a look at this example: https://stackoverflow.com/questions/39312903/running-webdriver-with-firefox-python – Xing-fu Jan 04 '19 at 21:21

1 Answers1

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.

finefoot
  • 9,914
  • 7
  • 59
  • 102