Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I am trying to use selenium from python to scrape some dynamics pages with javascript. However, I cannot call firefox after I followed the instruction of selenium on the pypi page(http://pypi.python.org/pypi/selenium). I installed firefox on AWS ubuntu 12.04. The error message I got is:

In [1]: from selenium import webdriver

In [2]: br = webdriver.Firefox()

---------------------------------------------------------------------------

WebDriverException                        Traceback (most recent call last)

/home/ubuntu/<ipython-input-2-d6a5d754ea44> in <module>()

----> 1 br = webdriver.Firefox()

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout)

     49         RemoteWebDriver.__init__(self,

     50             command_executor=ExtensionConnection("127.0.0.1", self.profile,

---> 51             self.binary, timeout),

     52             desired_capabilities=DesiredCapabilities.FIREFOX)

     53

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.pyc in __init__(self, host, firefox_profile, firefox_binary, timeout)

     45         self.profile.add_extension()

     46

---> 47         self.binary.launch_browser(self.profile)

     48         _URL = "http://%s:%d/hub" % (HOST, PORT)

     49         RemoteConnection.__init__(

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.pyc in launch_browser(self, profile)

     42

     43         self._start_from_profile_path(self.profile.path)

---> 44         self._wait_until_connectable()

     45

     46     def kill(self):

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.pyc in _wait_until_connectable(self)

     79                 raise WebDriverException("The browser appears to have exited "

     80                       "before we could connect. The output was: %s" %

---> 81                       self._get_firefox_output())

     82             if count == 30:

     83                 self.kill()

WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'

I did search on the web and found that this problem happened with other people (https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/21sJrOJULZY). But I don't understand the solution, if it is.

Can anyone help me please? Thanks!

1 Answer

0 votes
by (62.9k points)

I suppose you are on Firefox 47 and Selenium 2.53. So you need to downgrade the Firefox version from Firefox 47 to Firefox 45. You can follow the steps shown below:

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.00ubuntu0.16.04.1

Version: 45.0.20ubuntu1

3) Tell which build to download

sudo apt-get install firefox=45.0.20ubuntu1

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

I hope this resolves the issue!

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium online certification exam!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...