-1

I am using selenium to crawl a javascript website, the issue is that, a Firefox browser opens up, but the call for the URL is not done. however, when I close the browser, it is then that call for URL is done and of course I get the missing driver exception. what do you think the issue comes from.

knowing that:

  • all programs are up-to-date
  • my solution works fine, in local, but when I try to deploy it on the server, I start having issues

Example: at my local machine, I run this script and everything goes smooth, however when I run it a server (Linux), only the browser opens up and no get URL is called

from selenium import webdriver
import time

geckodriver_path = r'.../geckodriver'

driver = webdriver.Firefox(executable_path= geckodriver_path)
time.sleep(3)
driver.get("http://www.stackoverflow.com")
Alihossein shahabi
  • 4,034
  • 2
  • 33
  • 53
OUMOUSS_ELMEHDI
  • 499
  • 5
  • 16

1 Answers1

0

I end up finding the solution :

from selenium import webdriver
import time
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

geckodriver_path = r'/path_to/geckodriver'

binary = FirefoxBinary(r'/usr/bin/firefox')

capabilities = webdriver.DesiredCapabilities().FIREFOX
capabilities["marionette"] = False

driver = webdriver.Firefox(firefox_binary=binary,
                           executable_path= geckodriver_path,
                           capabilities=capabilities)

time.sleep(3)
driver.get("https://stackoverflow.com/")
time.sleep(6)
driver.close()

# solution from: 
# https://github.com/SeleniumHQ/selenium/issues/3884
# https://stackoverflow.com/questions/25713824/setting-path-to-firefox-binary-on-windows-with-selenium-webdriver
OUMOUSS_ELMEHDI
  • 499
  • 5
  • 16