unable to call firefox from selenium in python on AWS machine
The problem is Firefox requires a display. I've used pyvirtualdisplay in my example to simulate a display. The solution is:
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=False, size=(1024, 768))
display.start()
driver= webdriver.Firefox()
driver.get("http://www.somewebsite.com/")
<---some code--->
#driver.close() # Close the current window.
driver.quit() # Quit the driver and close every associated window.
display.stop()
Please note that pyvirtualdisplay requires one of the following back-ends: Xvfb, Xephyr, Xvnc.
This should resolve your issue.
I too had faced same problem.I was on Firefox 47 and Selenium 2.53. So what I did was downgraded Firefox to 45. This worked.
1) Remove Firefox 47 first :
sudo apt-get purge firefox
2) Check for available versions:
apt-cache show firefox | grep Version
It will show available firefox versions like:
Version: 47.0+build3-0ubuntu0.16.04.1
Version: 45.0.2+build1-0ubuntu1
3) Tell which build to download
sudo apt-get install firefox=45.0.2+build1-0ubuntu1
4) Next you have to not upgrade to the newer version again.
sudo apt-mark hold firefox
5) If you want to upgrade later
sudo apt-mark unhold firefox
sudo apt-get upgrade
Hope this helps.