2016-11-16 1 views
4

selenium-standalone을 Digital Ocean의 Ubuntu 서버에서 실행하려고합니다. 내가 서버에 ssh를, 다음에 다음 명령어를 실행하십시오 :Ubuntu 서버에서 selenal-standalone npm 패키지 실행하기

apt-get update 
apt-get install nodejs nodejs-legacy npm default-jre 
npm install selenium-standalone -g 
selenium-standalone install 
selenium-standalone start 

셀레늄 독립형 서버가 실행되고 있는지 멋진 메시지에 이르게 그! 그러나 내 컴퓨터에 간단한 스크립트에서 연결을 시도 :

var webdriver = require('selenium-webdriver'), 
    By = webdriver.By, 
    until = webdriver.until; 

var driver = new webdriver.Builder() 
     .forBrowser('chrome') 
     .usingServer('http://XXX.XXX.XXX.XX:4444/wd/hub') 
     .build(); 

나는 두 개의 큰 오류 메시지를 얻을. 서버에서 내가 얻을 : 서버에 연결을 시도

23:49:09.596 INFO - Executing: [new session: Capabilities [{browserName=chrome}]]) 
23:49:09.599 INFO - Creating a new session for Capabilities [{browserName=chrome}] 
Starting ChromeDriver 2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e) on port 13700 
Only local connections are allowed. 
23:49:09.644 WARN - Exception thrown 
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' 
System info: host: 'ubuntu-nodesele', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111' 
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:183) 
    at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119) 
    at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95) 
    at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124) 
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59) 
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1) 
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111) 
    at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79) 
    at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204) 
    at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) 
    at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680) 
    at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571) 
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526) 
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479) 
    at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920) 
    at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820) 
    at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986) 
    at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837) 
    at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243) 
    at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358) 
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537) 
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' 
System info: host: 'ubuntu-nodesele', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111' 
Driver info: driver.version: unknown 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97) 
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103) 
    ... 9 more 
Caused by: org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary 
    (Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 23 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' 
System info: host: 'ubuntu-nodesele', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111' 
Driver info: org.openqa.selenium.chrome.ChromeDriver 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144) 
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170) 
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138) 
    ... 14 more 
23:49:09.653 WARN - Exception: unknown error: cannot find Chrome binary 
    (Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 23 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' 
System info: host: 'ubuntu-nodesele', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111' 
Driver info: org.openqa.selenium.chrome.ChromeDriver 

그리고 내 컴퓨터에

는, 내가 얻을 :

WebDriverError: unknown error: cannot find Chrome binary 
    (Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 23 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' 
System info: host: 'ubuntu-nodesele', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111' 
Driver info: org.openqa.selenium.chrome.ChromeDriver 
    at WebDriverError (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/lib/error.js:27:5) 
    at Object.checkLegacyResponse (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/lib/error.js:505:15) 
    at parseHttpResponse (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/lib/http.js:509:13) 
    at doSend.then.response (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/lib/http.js:440:13) 
    at process._tickCallback (internal/process/next_tick.js:103:7) 
From: Task: WebDriver.createSession() 
    at Function.createSession (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/lib/webdriver.js:777:24) 
    at Function.createSession (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/chrome.js:709:29) 
    at createDriver (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/index.js:167:33) 
    at Builder.build (/Users/liamgray/webdriverio-test/node_modules/selenium-webdriver/index.js:623:16) 
    at new Bot (/Users/liamgray/webdriverio-test/test.js:17:8) 
    at Object.<anonymous> (/Users/liamgray/webdriverio-test/test.js:122:11) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 

이 크롬에 설치되지 않았 음을 말하고있는 오류 것 같아 서버를 올바르게 하지만 그 명령은 selenium-standalone install 명령 중에 발생한다고 생각 했습니까?

올바른 방향의 모든 포인터를 환영합니다!

답변

7

셀레늄 독립 실행 형 패키지는 셀렌 &을 설치합니다. 브라우저 자체가 아닌 브라우저 드라이버입니다.

Selenium은 특정 브라우저와 상호 작용할 수있는 브라우저 드라이버가 필요합니다. 귀하의 경우에는 크롬 드라이버가 필요하며 서버에 설치되어 있습니다. 하지만 브라우저가 없습니다.

this page을 참조하여 크롬을 설치할 수 있습니다. 크롬을 안정적으로 설치하는 것이 좋습니다

+1

이 답변에 추가하려면 (올바른 것으로 생각됩니다) 브라우저에서 * in * 서버를 실행하려면 'Xvfb'와 같은 것이 필요할 수도 있습니다. 이 게시물을 통해 비슷한 환경에서 필요한 것을 얻을 수있었습니다. http://elementalselenium.com/tips/38-headless –

+1

와우 ...이 답변으로 제 목숨을 구했습니다. 이것은 헤드리스 브라우저로 우분투에서 실행되도록 셀레늄을 얻는 해결책입니다. – Sam