问题
I'm trying to use Protractor on a virtual machine and am getting the error code 199.
I am following this tutorial with the exact same steps - http://www.protractortest.org/#/tutorial
When I enter protractor conf.js on the command line, I get the following error:
[14:51:31] I/hosted - Using the selenium server at (my url here)
[14:51:31] I/launcher - Running 1 instances of WebDriver
[14:51:51] E/launcher - null
[14:51:51] E/launcher - WebDriverError: null
at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:197:43)
at /usr/local/lib/node_modules/protractor/built/runner.js:276:30
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[14:51:51] E/launcher - Process exited with error code 199
The problem is not connecting to the webdriver as I have exposed a port and able to access the url and view the hub for it.
Thanks.
回答1:
After a lot of prodding, running strace
, running manually etc I managed to get to the bottom of this on debian/devuan. If I ran chromium
by hand it worked fine (Chrome would appear and I could browse). However every time I ran protractor
there would a long hang followed by:
E/launcher - null
E/launcher - WebDriverError: null
strace
of protractor
was showing selenium
was returning a 500 series error. Looking at ps uwww
allowed me to see that the following command was being executed:
java -Dwebdriver.chrome.driver=.../webdriver-manager/selenium/chromedriver_2.26
-jar .../selenium-server-standalone-2.53.1.jar -port 60987
Running this manually, connecting to the instance, creating a new session and selecting chrome gave the error:
.../webdriver-manager/selenium/chromedriver_2.26: error while loading shared libraries:
libgconf-2.so.4: cannot open shared object file: No such file or directory
On installing libgconf2
with apt-get install libgconf-2-4
(on Devuan Jessie) this then fixed both the manually created selenium
instance and the protractor
test.
来源:https://stackoverflow.com/questions/40999672/protractor-for-nodejs-on-a-virtual-machine-how-do-i-fix-error-199