Reputation: 5580
I have followed the instructions at Setting up PhantomJS.
Please find the directory structure as follows
吽 find . -name phantomjs; ll
./node_modules/.bin/phantomjs
./node_modules/phantomjs
./node_modules/phantomjs/bin/phantomjs
./node_modules/phantomjs/lib/phantom/bin/phantomjs
total 16
-rw-r--r-- 1 sarbbo Y\Domain Users 1269 Mar 23 12:02 specs.js
drwxr-xr-x 4 sarbbo Y\Domain Users 136 Mar 23 12:08 node_modules
-rw-r--r-- 1 sarbbo Y\Domain Users 204 Mar 23 12:25 conf.js
the contents of the conf.js is as below mentioned.
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['specs.js'],
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': require('phantomjs').path
}
}
Works as desired for capabilities: {'browserName': 'chrome'}
When protractor conf.js
is excuted, following error is displayed:
by webdriver-manager [webdriver-manager has been started with webdriver-manager start
command]
12:41:41.043 INFO - Executing: [new session: Capabilities [{phantomjs.binary.path=/Users/sarbbo/GitHub/protractor/node_modules/phantomjs/lib/phantom/bin/phantomjs, count=1, browserName=phantomjs}]])
12:41:41.052 INFO - Creating a new session for Capabilities [{phantomjs.binary.path=/Users/sarbbo/GitHub/protractor/node_modules/phantomjs/lib/phantom/bin/phantomjs, count=1, browserName=phantomjs}]
12:41:41.054 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'rushpress-lm', ip: '10.73.199.247', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.2', java.version: '1.8.0_25'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:108)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
at org.openqa.12:41:41.059 WARN - Exception: org.openqa.selenium.browserlaunchers.Proxies
and by protractor ERROR - Unable to start a WebDriver session.
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
var template = new Error(this.message);
^
UnknownError: org.openqa.selenium.browserlaunchers.Proxies
at new bot.Error (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
at resolve (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
at fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:149:22)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:123:30)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:294:22)
at DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:50:7)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:178:37)
at /usr/local/lib/node_modules/protractor/lib/runner.js:259:24
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
[launcher] Process exited with error code 1
Any pointer would be of great help.
Thanks
Upvotes: 3
Views: 5669
Reputation: 5580
Updating the protractor solved the issue, which uses selenium-server-standalone-2.45.0.jar
You might need to execute the following commands with sudo
.
npm i protractor -g
webdriver-manager update
Update 26-MAR-2015
The above works well with phantomjs-1.9.8 but not phantomjs-2.0.0. I updated phantomjs version locally and installed from the local copy.
Same issue happened. Looks like, selenium-server-standalone-2.45.0.jar is not compatible with phantomjs-2.0.0
TL;DR
While searching for the solution I came across
Downgrading back to version 2.43.1 fixes the issue, so i suspect a change in 2.44.0 has broken the ability to use PhantomJS on the grid.
at Issue 8102: PhantomJS Doesn't Work on Selenium Grid 2.44.0
The selenium-server-standalone
present at /usr/local/lib/node_modules/protractor/selenium
in my system was also selenium-server-standalone-2.44.0.jar
So, I tried to look for downgrading selenium-server-standalone
via webdriver-manager
, but could not find any appropriate option.
吽 webdriver-manager --help
Usage: webdriver-manager <command>
Commands:
update: install or update selected binaries
start: start up the selenium server
status: list the current available drivers
Options:
--out_dir Location to output/expect [default: "/usr/local/lib/node_modules/protractor/selenium"]
--seleniumPort Optional port for the selenium standalone server
--ignore_ssl Ignore SSL certificates [default: false]
--proxy Proxy to use for the install or update command
--alternate_cdn Alternate CDN to the binaries
--standalone Install or update selenium standalone [default: true]
--chrome Install or update chromedriver [default: true]
--ie Install or update IEDriver [default: false]
Please specify one command
So I downloaded selenium-server-standalone-2.43.1.jar
via curl
at /usr/local/lib/node_modules/protractor/selenium
sudo curl -O https://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar
However on starting webdriver-manager, via webdriver-manager start
command, displayed the following message.
Selenium Standalone is not present. Install with webdriver-manager update --standalone
I just dowloaded the selenium-server-standalone-2.43.1.jar
, but why webdriver-manager
is complaining?
On looking into the webdriver-manager code at /usr/local/lib/node_modules/protractor
, I noticed the following:
if (!binaries.standalone.exists) {
console.error('Selenium Standalone is not present. Install with ' +
'webdriver-manager update --standalone');
process.exit(1);
}
It was trying to match the existence of the selenium-server-standalone
in accordance to /usr/local/lib/node_modules/protractor/config.json
Following had been the contents of /usr/local/lib/node_modules/protractor/config.json
{
"webdriverVersions": {
"selenium": "2.44.0",
"chromedriver": "2.14",
"iedriver": "2.44.0"
}
}
On updating the protractor /usr/local/lib/node_modules/protractor/config.json
got updated to
{
"webdriverVersions": {
"selenium": "2.45.0",
"chromedriver": "2.14",
"iedriver": "2.45.0"
}
}
And then executing the webdriver-manager update
installed selenium-server-standalone-2.45.0.jar
along with chromedriver
.
Now, on executing protractor conf.js
it performed as expected.
Upvotes: 3