I am trying to open Firefox with selenium,i tried
from selenium import webdriver
driver=webdriver.Firefox()
But i got the following error:
selenium.common.exceptions.WebDriverException: Message: 'firefox' executable needs to be in PATH.
Selenium using Python - Geckodriver executable needs to be in PATH
I tried
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('/usr/bin/firefox')
browser = webdriver.Firefox(firefox_binary=binary)
Also tried
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
caps['marionette'] = True
caps['binary'] = '/usr/bin/firefox'
d = webdriver.Firefox(capabilities=caps)
`but still did not work.
However, when i tried using the above code replacing the last line with
d=webdriver.Firefox(capabilities=caps,executable_path='/usr/bin/firefox')
and having my Firefox closed from background it would open Firefox but I can't simply d.get("https://www.google.com")
it gets stuck on Linux homepage and doesn't open anything.
After typing whereis firefox
in terminal i got /usr/bin/firefox
,also if it matters i use python 2.7
Note: I hope this isn't a duplicate of the above link because i tried the answers and it didn't fix it.
I installed geckodriver from github, and tried browser=webdriver.Firefox(executable_path="geckodriver")
,I have placed the driver is the same directory.