Nathan Friedly
Nathan Friedly

Reputation: 8146

How to run Selenium Server on Travis CI when testing a Node.js project with Nightwatch

I have a node.js project that I am trying to use Nightwatch to test. Nightwatch uses selenium-server under-the-hood.

My tests work correctly locally, but on Travis it immediately chokes with this error:

There was an error while starting the Selenium server:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncherV3 : Unsupported major.minor version 52.0

I think that means that it wants Java 8 or newer, but I'm not sure how to set that up on Travis. I tried setting jdk: oracle8jdk in my travis.yml, but that didn't seem to make a difference. (Maybe that only works on for Java tests?)

Any suggestions?

Upvotes: 3

Views: 510

Answers (1)

Nathan Friedly
Nathan Friedly

Reputation: 8146

The Trusty Environment has a tool called jdk_switcher installed. That tool can be used to set up the correct version of Java for running selenium. Here's the important parts of my travis.yml:

dist: trusty
sudo: false
#...
before_script:
    #...
    - jdk_switcher use oraclejdk8

Upvotes: 2

Related Questions