2

I am facing this exception when I run a Selenium test case using the Firefox driver on the AWS EC2 instance which is the headless server. I installed Firefox and all the necessary changes for it

org.openqa.selenium.WebDriverException: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/opt/firefox/firefox-bin) on port 7055; process output follows: �*** e = [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]" nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" location: "JS frame :: chrome://browser/content/utilityOverlay.js :: getShellService :: line 339" data: no]

Please can anyone help me with this exception?

Bill the Lizard
  • 352
  • 1
  • 7
  • 15
mahesh more
  • 121
  • 1
  • 3

2 Answers2

3

First install xvfb which will allow you to run it with a "virtual screen".

sudo yum -y install xorg-x11-server-Xvfb 

Then you should check out this helpful post which will help you get firefox installed on amazon EC2. This is because you can't just do sudo yum install firefox on EC2. So, basically you create a file (I used this gist) on the EC2 instance that he provides and then run it to install firefox and all of it's dependancies. http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/

When the script runs it will install firefox in

/usr/local/bin/firefox

by default I believe.

Once it has installed you probably then need to add it to your path as the above link also explains. But you should also add the DISPLAY system variable though so do something like this...

cat << EOF >> ~/.bashrc
PATH=/usr/local/bin:\$PATH
DISPLAY=:99
export PATH
export DISPLAY
EOF

Then you have to kick off xvfb for screen 99 so it will be able to run firefox on it's "virtual screen". Like so...

Xvfb :99 -screen 0 1024x768x16 &

Then hopefully when you re-run your selenium tests it will find firefox on the path and run it in the correct "virtualised" screen on that EC2 instance.

As a side note - I am not by any means an expert of any type in amazon linux so... Goodluck.

Alternatively, you could investigate running against selenium server which you could fire up on an amazon EC2 ubuntu micro instance, which you can easily setup to have a GUI.

dawogfather
  • 131
  • 4
  • how do you run your selenium tests? after doing everything thrice, I get this error: PuTTY X11 proxy: wrong authorisation protocol attemptedError: cannot open display: localhost:10.0 – Buffalo Sep 03 '15 at 14:44
0

Failed to connect to binary FirefoxBinary(/opt/firefox/firefox-bin) on port 7055

You need to upgrade your Selenium Server (to 2.53.x), so it can support your newer version of Firefox. Alternatively use another webdriver (such as Chrome).

If you're using Maven, here are the lines to use in pom.xml:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.53.1</version>
  <scope>test</scope>
</dependency>

See:

kenorb
  • 5,943
  • 1
  • 44
  • 53