Unable to initialise FireFox using webdriver when running the test through Robot Framework

1,203 views
Skip to first unread message

James

unread,
Nov 21, 2011, 11:19:24 PM11/21/11
to robotframework-users
Hi all,

I have created a framework for automated testing which uses webdriver
as one of it's drivers. I had originally created the tests inside the
java code, but have since exposed a keyword framework and testers have
started writing tests in fitnesse. When creating a test the users can
specify a (or multiple) browser(s) which they want the test to run on;
by default we run our tests on Firefox. When running tests created in
java and those which hit the keyword framework written in fitnesse
Firefox initialises correctly and the tests run.

Unfortunately some of the testers here are finding fitnesse a tad
difficult to use, so we are now migrating to Robot Framework.
Currently though when I run my test I get the following error in the
Robot Framework log:

"ExceptionInInitializerError"

This is all that I am given, and hence all that I can tell you about
my error. I have tried to capture exceptions and print the stack
trace, but nothing seems to get logged. The tests executes correctly
if I run it using Internet Explorer or Chrome, it just fails on
Firefox. It fails on the line:

driver = selenium = new FirefoxDriver();

Again this causes no errors when run in java or in fitnesse, and Robot
Framework tests work with IE and chrome. Does anyone have any ideas
on how to fix this issue?

The only similar issues I have seen revolve around profiles:
http://groups.google.com/group/selenium-users/browse_thread/thread/52d1e222445958d7/5d56996a4f14aefe?lnk=gst&q=initialise+firefox#5d56996a4f14aefe

http://groups.google.com/group/selenium-users/browse_thread/thread/357e3288b71e0c7b/892d36ae9a743901?lnk=gst&q=initialise+firefox#892d36ae9a743901

http://stackoverflow.com/questions/7929037/selenium-python-webdriver-and-firefox-profiles

So I guess I will go down that track and hope I can stumble upon
something.


Thanks in advance,
James

James

unread,
Nov 21, 2011, 11:40:26 PM11/21/11
to robotframework-users
I have just tried to create a new profile and made sure that I have
the system property for my firefox binary set
                System.setProperty("webdriver.firefox.bin", "C:\
\Program Files (x86)\\Mozilla Firefox\\firefox.exe");       
FirefoxProfile firefoxProfile = new FirefoxProfile();       
try{selenium = new FirefoxDriver(firefoxProfile);}catch(Exception e)
{e.printStackTrace();}
However I still get the error

On Nov 22, 5:19 pm, James <jamesfarr...@gmail.com> wrote:
> Hi all,
>
> I have created a framework for automated testing which uses webdriver
> as one of it's drivers.  I had originally created the tests inside the
> java code, but have since exposed a keyword framework and testers have
> started writing tests in fitnesse.  When creating a test the users can
> specify a (or multiple) browser(s) which they want the test to run on;
> by default we run our tests on Firefox.  When running tests created in
> java and those which hit the keyword framework written in fitnesse
> Firefox initialises correctly and the tests run.
>
> Unfortunately some of the testers here are finding fitnesse a tad
> difficult to use, so we are now migrating to Robot Framework.
> Currently though when I run my test I get the following error in the
> Robot Framework log:
>
> "ExceptionInInitializerError"
>
> This is all that I am given, and hence all that I can tell you about
> my error.  I have tried to capture exceptions and print the stack
> trace, but nothing seems to get logged.  The tests executes correctly
> if I run it using Internet Explorer or Chrome, it just fails on
> Firefox.  It fails on the line:
>
> driver = selenium = new FirefoxDriver();
>
> Again this causes no errors when run in java or in fitnesse, and Robot
> Framework tests work with IE and chrome.  Does anyone have any ideas
> on how to fix this issue?
>
> The only similar issues I have seen revolve around profiles:http://groups.google.com/group/selenium-users/browse_thread/thread/52...
>
> http://groups.google.com/group/selenium-users/browse_thread/thread/35...
>
> http://stackoverflow.com/questions/7929037/selenium-python-webdriver-...

James

unread,
Nov 21, 2011, 11:49:53 PM11/21/11
to robotframework-users
Any chance you guys know how I can get some better logs out?

Janne Härkönen

unread,
Nov 22, 2011, 12:31:04 AM11/22/11
to jamesf...@gmail.com, robotframework-users
Hello James

On Tue, Nov 22, 2011 at 6:19 AM, James <jamesf...@gmail.com> wrote:
> Unfortunately some of the testers here are finding fitnesse a tad
> difficult to use, so we are now migrating to Robot Framework.
> Currently though when I run my test I get the following error in the
> Robot Framework log:
>
> "ExceptionInInitializerError"
>
> This is all that I am given, and hence all that I can tell you about
> my error.  I have tried to capture exceptions and print the stack
> trace, but nothing seems to get logged.  The tests executes correctly
> if I run it using Internet Explorer or Chrome, it just fails on
> Firefox.  It fails on the line:
>
> driver = selenium = new FirefoxDriver();
>
> Again this causes no errors when run in java or in fitnesse, and Robot
> Framework tests work with IE and chrome.  Does anyone have any ideas
> on how to fix this issue?

I am not user what the problem is, but most likely it is related to
the environment.

Have you considered using one of the ready-made Selenium libraries?
There's one using the old Selenium remote control [1] and another
using the Webdriver API [2]. Using one of these could considerably
lessen your own maintenance burden, and these should work with all
reasonable browsers.

[1] http://code.google.com/p/robotframework-seleniumlibrary/
[2] https://github.com/rtomac/robotframework-selenium2library

thanks,
--J


---
Janne Härkönen | http://reaktor.fi
http://twitter.com/#!/janneharkonen

James Farrier

unread,
Nov 22, 2011, 12:45:45 AM11/22/11
to Janne Härkönen, robotframework-users
Hi Janne,

Unfortunately there are some commands that I have implemented in our framework that would be difficult to recreate using these libraries.  It probably doesn't help that my python is quite bad.  I didn't know about the webdriver version so I will check that out and see if they do anything clever to prevent this issue.

Thanks,
James

Jussi Malinen

unread,
Nov 22, 2011, 9:41:23 AM11/22/11
to jamesf...@gmail.com, Janne Härkönen, robotframework-users
Hi James!

By default robot framework eats your stdout (which go to log) and
stack traces (which are discarded). If you set the log level to debug
or trace, you will get the stack trace to log.

So try running your tests with commandline option "--loglevel DEBUG"

Regards,
Jussi


--
Jussi Malinen / Robot Framework
Reaktor, www.reaktor.fi

> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to
> robotframework-u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/robotframework-users?hl=en.
>

James

unread,
Nov 22, 2011, 4:30:35 PM11/22/11
to robotframework-users
Thanks very much Jussi,

I've managed to get the logs which say:

DEBUG java.lang.ExceptionInInitializerError
at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
83)

Caused by: java.lang.NullPointerException
at
org.openqa.selenium.firefox.FirefoxBinary.<clinit>(FirefoxBinary.java:
45)

I don't understand how this can happen given I have set the system
properties to the exe and it runs using fitnesse and through java...

I'm going to look through the library Janne linked and see if that has
any hints.

Thanks again,
James

On Nov 23, 3:41 am, Jussi Malinen <jussi.ao.mali...@gmail.com> wrote:
> Hi James!
>
> By default robot framework eats your stdout (which go to log) and
> stack traces (which are discarded). If you set the log level to debug
> or trace, you will get the stack trace to log.
>
> So try running your tests with commandline option "--loglevel DEBUG"
>
> Regards,
> Jussi
>
> --
> Jussi Malinen / Robot Framework
> Reaktor,www.reaktor.fi
>
>
>
>
>
>
>
> On Tue, Nov 22, 2011 at 7:45 AM, James Farrier <jamesfarr...@gmail.com> wrote:
> > Hi Janne,
> > Unfortunately there are some commands that I have implemented in our
> > framework that would be difficult to recreate using these libraries.  It
> > probably doesn't help that my python is quite bad.  I didn't know about the
> > webdriver version so I will check that out and see if they do anything
> > clever to prevent this issue.
> > Thanks,
> > James
>

> > On 22 November 2011 18:31, Janne Härkönen <janne.t.harko...@gmail.com>
> > wrote:
>
> >> Hello James

James

unread,
Nov 22, 2011, 5:28:01 PM11/22/11
to robotframework-users
I have upgraded to the most recent release of selenium still no dice.

11:01:23.784 DEBUG java.lang.ExceptionInInitializerError at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
81) at
scenario.framework.driver.Selenium2Driver.initialiseDriver(Selenium2Driver.java:
172) at
scenario.framework.driver.Selenium2Driver.initialise(Selenium2Driver.java:
123) at
scenario.framework.main.ScenarioFramework.initiate(ScenarioFramework.java:
118) at
scenario.framework.main.ScenarioFramework.<init>(ScenarioFramework.java:
103) at scenario.framework.testcase.TestCase.start(TestCase.java:71)
at scenario.framework.testcase.TestCase.start(TestCase.java:59) at
scenario.framework.main.Keyword.startFramework(Keyword.java:116) at
scenario.framework.main.Keyword.startFramework(Keyword.java:132) at
robot.jarrunner$py.run$2(/home/mkorpela/workspace/robot263/tmp-jar-dir/
Lib/robot/jarrunner.py:29) at robot.jarrunner$py.call_function(/home/
mkorpela/workspace/robot263/tmp-jar-dir/Lib/robot/jarrunner.py) at
org.robotframework.RobotFramework.run(RobotFramework.java:43) at
org.robotframework.RobotFramework.main(RobotFramework.java:29)Caused


by: java.lang.NullPointerException at
org.openqa.selenium.firefox.FirefoxBinary.<clinit>(FirefoxBinary.java:

42) ... 183 more
So the code in question ends up beingFirefoxBinary ln42-43 private
static final String PATH_PREFIX = "/" +     
FirefoxBinary.class.getPackage().getName().replace(".", "/") + "/";
and FirefoxDriver ln 80-82public FirefoxDriver(FirefoxProfile profile)
{    this(new FirefoxBinary(), profile);  }
It also fails in the below if I remove the profile I had addedpublic
FirefoxDriver() {    this(new FirefoxBinary(), null);  }
I have put my firefox binary in my classpath, path, and set it in the
system properties.
Further I added the following linesDesiredCapabilities cap = new
DesiredCapabilities();        cap.setCapability(FirefoxDriver.BINARY,
"C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");and included
the capabilities when launching firefox driver


And now I get the error:11:22:49.424 DEBUG
java.lang.ExceptionInInitializerError at
org.openqa.selenium.firefox.FirefoxDriver.getBinary(FirefoxDriver.java:
120) at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
85) at
scenario.framework.driver.Selenium2Driver.initialiseDriver(Selenium2Driver.java:
177) at
scenario.framework.driver.Selenium2Driver.initialise(Selenium2Driver.java:
123) at
scenario.framework.main.ScenarioFramework.initiate(ScenarioFramework.java:
118) at
scenario.framework.main.ScenarioFramework.<init>(ScenarioFramework.java:
103) at scenario.framework.testcase.TestCase.start(TestCase.java:71)
at scenario.framework.testcase.TestCase.start(TestCase.java:59) at
scenario.framework.main.Keyword.startFramework(Keyword.java:116) at
scenario.framework.main.Keyword.startFramework(Keyword.java:132) at
robot.jarrunner$py.run$2(/home/mkorpela/workspace/robot263/tmp-jar-dir/
Lib/robot/jarrunner.py:29) at robot.jarrunner$py.call_function(/home/
mkorpela/workspace/robot263/tmp-jar-dir/Lib/robot/jarrunner.py) at
org.robotframework.RobotFramework.run(RobotFramework.java:43) at
org.robotframework.RobotFramework.main(RobotFramework.java:29)Caused


by: java.lang.NullPointerException at
org.openqa.selenium.firefox.FirefoxBinary.<clinit>(FirefoxBinary.java:

42) ... 184 more

which means it is failing in the below:
private static FirefoxBinary getBinary(Capabilities capabilities) {   
if (capabilities.getCapability(BINARY) != null) {      File file = new
File((String) capabilities.getCapability(BINARY));      return new
FirefoxBinary(file);    }    return new FirefoxBinary();  }
public FirefoxDriver(Capabilities capabilities) {   
this(getBinary(capabilities), extractProfile(capabilities));  }

I don't understand where else I can set this binary... or why it can't
seem to pick it up.

David

unread,
Nov 22, 2011, 7:12:46 PM11/22/11
to robotframework-users
> I don't understand how this can happen given I have set the system
> properties to the exe and it runs using fitnesse and through java...

Are you importing your library as a Java library and running
RobotFramework (RF) via Jython? That may be the only difference
between RF and using your library through FitNess and Java. I'm
assuming the FitNesse fixtures are implemented in pure Java and not
run via Jython, etc.

To help with debugging and as a temporary workaround, you could also
try importing your webdriver library as a remote library running in
pure Java (no Jython) and see if any issues come up there. If you
don't want to build your own remote library server/interface, you
could take a look at

http://code.google.com/p/jrobotremoteserver/

James

unread,
Nov 22, 2011, 8:03:12 PM11/22/11
to robotframework-users
Hi David,

I can't see a reason why that would only affect Firefox though. At
the moment I am running the test using java -jar robotframework.jar --
pythonpath framweork.jar test.tsv.

Regards,
James

James

unread,
Nov 22, 2011, 11:06:00 PM11/22/11
to robotframework-users
Hi David,

I ran the remote server using the following:
java -cp .;xmlrpc-1.1.1.jar;simple-xmlrpc-1.0.jar;simple-4.0.1.jar;c:
\Users\farriej\Dropbox\WorkSpace\ScenarioFramework\target
\ScenarioFramework-jar-with-dependencies.jar
org.robotframework.remotelibra
ry.RemoteServer --library scenario.framework.main.Keyword

and then tried to run the test with:

java -jar robotframework-2.6.3.jar test.tsv

but I got the error

[ ERROR ] Error in file 'C:\robot\test.tsv' in table 'Setting':
Importing test library 'scenario.framework.main.Keyword' failed:
ImportError: No module named scenario
PYTHONPATH: ['C:\\robot\\robotframework-2.6.3.jar\\Lib\\robot\
\libraries', 'C:\\robot\\Lib', 'C:\\robot\\robotframework-2.6.3.jar\
\Lib', '__classpath__', '__pyclasspath__/', '.']
CLASSPATH: robotframework-2.6.3.jar
Traceback (most recent call last):
File "C:\robot\robotframework-2.6.3.jar\Lib\robot\utils\importing
$py.class", line 107, in _dotted_import
==============================================================================
Test
==============================================================================
Simple Test
| FAIL |
No keyword with name 'Start Framework' found.


Any ideas?

David

unread,
Nov 23, 2011, 4:31:41 AM11/23/11
to robotframework-users
Hi James,

Yes I know that doesn't seem like a reason, but that's the only clear
difference between how tests are run - pure Java invocation of your
library vs invocation through Jython. Asside from that, I don't see
how the rest of RF (Python parts) would come into play regarding the
issue.

It probably doesn't matter, but just to rule out issues with using
robotframework.jar, you could also try running your test the same way
but run RF via the formal Jython method rather than the standalone
JAR. That is, install Jython, Python, and RF, then run RF via Jython
instead of your current JAR method. See RF user guide for details on
how to run via Jython.

http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.2#starting-test-execution

David

unread,
Nov 23, 2011, 4:47:53 AM11/23/11
to robotframework-users
Hi James,

Based on the error you received, you might want to read up on the
remote library approach for RF. Libraries are imported differently in
the RF tests when using remote libraries, so you'll have to make an
alternate copy of the test suite to try this out.

See http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.2#taking-remote-library-into-use

If you use the defaults with my Java server, then the following could
be used:

Setting|Value|Value|Value|Value
Library|Remote|http://localhost:8270|WITH NAME|My Remote Library Name
For Reference

The "with name" and value after are optional, just helps for reference
and referencing in the test cases in case of multiple library
namespace conflicts.

Also good to review the overall details of the remote library
interface to know what you're using.

http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.2#remote-library-interface

Also to note, I only have a simple example test library bundled for
evaluating and testing the Java XML-RPC remote library server. As I
don't have enough "beta" testers for the library, more complex Java
libraries may or may not work with the server. One can check the
source code for the server and review the RF specification (in user
guide) for static and dynamic APIs to gauge whether a Java library
will work with the server. Hopefully yours works with my server. It
seems you were able to start the server with your library, so that's a
good start.

Let me know if you have further issues with the Java server.

One last note, you can also test and debug your library with the Java
server over pure XML-RPC calls (or via XML-RPC client in Java, etc.)
outside of running library via RF via remote library interface. RF
simply calls the remote library over XML-RPC the same way, so if it
works making the manual XML-RPC calls then it should definitely work
under RF as a remote library. But that's only if you need to go this
far and take this route.

Regards,
David

On Nov 22, 8:06 pm, James <jamesfarr...@gmail.com> wrote:
> Hi David,
>

Reply all
Reply to author
Forward
0 new messages