无法在 Selenium Standalone 上创建 FF/Chrome 会话
Cannot create FF/Chrome session on Selenium Standalone
机器详细信息
AME="Amazon Linux AMI"
VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
我是单独使用 selenium 的新手。我已经下载了最新的 java 版本,独立使用 NPM,XVFB 并尝试在使用以下命令打开独立后创建会话:
sudo xvfb-run --server-args="-screen 0, 1366x768x24" selenium-standalone start -- -debug
另请注意,我已尝试使用 Hub 和 Node 进行此操作,还尝试在我的本地客户端上使用 C# 运行 Selenium 测试。
当我尝试创建 Chrome 会话时收到此错误(轮询将持续几秒钟):
DEBUG - Waiting for [http://localhost:29837/status]
DEBUG - Polling http://localhost:29837/status
/usr/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.32-
x64-chromedriver: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
DEBUG - Polling http://localhost:29837/status
DEBUG - Polling http://localhost:29837/status
DEBUG - Polling http://localhost:29837/status
ERROR - org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
^C/usr/bin/xvfb-run: line 171: kill: (6252) - No such process
尝试创建 Firefox 会话时:
14:30:26.416 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
14:30:26.418 INFO - Found handler: org.openqa.selenium.remote.server.BeginSession@44e7a749
14:30:26.418 INFO - /session: Executing POST on /session (handler: BeginSession)
14:30:26.442 DEBUG - Memory-based payload for: {desiredCapabilities={browserName=firefox}}
14:30:26.453 INFO - Capabilities are: Capabilities {browserName=firefox}
14:30:26.457 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
14:30:26.458 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
1506349826497 geckodriver INFO geckodriver 0.18.0
1506349826501 geckodriver INFO Listening on 127.0.0.1:5611
DEBUG - CookieSpec selected: default
DEBUG - Auth cache not set in the context
DEBUG - Connection request: [route: {}->http://localhost:5611][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
DEBUG - Connection leased: [id: 0][route: {}->http://localhost:5611][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
DEBUG - Opening connection {}->http://localhost:5611
DEBUG - Connecting to localhost/127.0.0.1:5611
DEBUG - Connection established 127.0.0.1:59276<->127.0.0.1:5611
DEBUG - http-outgoing-0: set socket timeout to 10800000
DEBUG - Executing request POST /session HTTP/1.1
DEBUG - Target auth state: UNCHALLENGED
DEBUG - Proxy auth state: UNCHALLENGED
DEBUG - http-outgoing-0 >> POST /session HTTP/1.1
DEBUG - http-outgoing-0 >> Content-Type: application/json; charset=utf-8
DEBUG - http-outgoing-0 >> Content-Length: 49
DEBUG - http-outgoing-0 >> Host: localhost:5611
DEBUG - http-outgoing-0 >> Connection: Keep-Alive
DEBUG - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
DEBUG - http-outgoing-0 >> Accept-Encoding: gzip,deflate
DEBUG - http-outgoing-0 >> "POST /session HTTP/1.1[\r][\n]"
DEBUG - http-outgoing-0 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
DEBUG - http-outgoing-0 >> "Content-Length: 49[\r][\n]"
DEBUG - http-outgoing-0 >> "Host: localhost:5611[\r][\n]"
DEBUG - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
DEBUG - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)[\r][\n]"
DEBUG - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
DEBUG - http-outgoing-0 >> "[\r][\n]"
DEBUG - http-outgoing-0 >> "{"desiredCapabilities":{"browserName":"firefox"}}"
DEBUG - http-outgoing-0 << "HTTP/1.1 500 Internal Server Error[\r][\n]"
DEBUG - http-outgoing-0 << "Connection: close[\r][\n]"
DEBUG - http-outgoing-0 << "Content-Type: application/json; charset=utf-8[\r][\n]"
DEBUG - http-outgoing-0 << "Cache-Control: no-cache[\r][\n]"
DEBUG - http-outgoing-0 << "Content-Length: 1337[\r][\n]"
DEBUG - http-outgoing-0 << "Date: Mon, 25 Sep 2017 14:30:27 GMT[\r][\n]"
DEBUG - http-outgoing-0 << "[\r][\n]"
DEBUG - http-outgoing-0 << "{"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":"stack backtrace:\n 0: 0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d\n 1: 0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0\n 2: 0x44da3d - geckodriver::marionette::MarionetteHandler::create_connection::h6f7058fccafe4367\n 3: 0x425c32 - <webdriver::server::Dispatcher<T, U>>::run::h8f5348b8f5f7c053\n 4: 0x40b22c - std::panicking::try::do_call::hb67c6fb6bcd96195\n 5: 0x5dc20a - panic_unwind::__rust_maybe_catch_panic\n at /checkout/src/libpanic_unwind/lib.rs:98\n 6: 0x41b943 - <F as alloc::boxed::FnBox<A>>::call_box::h4100941edc372034\n 7: 0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>\n at /checkout/src/liballoc/boxed.rs:650\n - std::sys_common::thread::start_thread\n at /checkout/src/libstd/sys_common/thread.rs:21\n - std::sys::imp::thread::{{impl}}::new::thread_start\n at /checkout/src/libstd/sys/unix/thread.rs:84"}}"
DEBUG - http-outgoing-0 << HTTP/1.1 500 Internal Server Error
DEBUG - http-outgoing-0 << Connection: close
DEBUG - http-outgoing-0 << Content-Type: application/json; charset=utf-8
DEBUG - http-outgoing-0 << Cache-Control: no-cache
DEBUG - http-outgoing-0 << Content-Length: 1337
DEBUG - http-outgoing-0 << Date: Mon, 25 Sep 2017 14:30:27 GMT
DEBUG - http-outgoing-0: Close connection
DEBUG - Connection discarded
DEBUG - Connection released: [id: 0][route: {}->http://localhost:5611][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
尝试运行此命令安装最新的稳定版GoogleChrome:
sudo yum -y localinstall google-chrome-stable_current_x86_64.rpm
或
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
我收到此错误:
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgdk-3.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libXss.so.1()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libatk-1.0.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgdk_pixbuf-2.0.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgconf-2.so.4()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgtk-3.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: xdg-utils
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
有没有人遇到过这个问题并且无论如何都可以解决这个问题?如果您有任何问题,请告诉我。
我无法在 Linux AMI 上安装这些库,但我最终将其安装在 Ubuntu 实例上。这使得使用以下文档的安装非常简单:
https://www.npmjs.com/package/selenium-standalone
但是,我的 Ubuntu linux 也收到了一个二进制错误。问题是我的 Linux 机器上没有安装浏览器,但我可以使用此处的说明进行安装:
https://askubuntu.com/questions/510056/how-to-install-google-chrome
也适用于 FireFox:
#install firefox browser
sudo apt-get install firefox
机器详细信息
AME="Amazon Linux AMI"
VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
我是单独使用 selenium 的新手。我已经下载了最新的 java 版本,独立使用 NPM,XVFB 并尝试在使用以下命令打开独立后创建会话:
sudo xvfb-run --server-args="-screen 0, 1366x768x24" selenium-standalone start -- -debug
另请注意,我已尝试使用 Hub 和 Node 进行此操作,还尝试在我的本地客户端上使用 C# 运行 Selenium 测试。
当我尝试创建 Chrome 会话时收到此错误(轮询将持续几秒钟):
DEBUG - Waiting for [http://localhost:29837/status]
DEBUG - Polling http://localhost:29837/status
/usr/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.32-
x64-chromedriver: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
DEBUG - Polling http://localhost:29837/status
DEBUG - Polling http://localhost:29837/status
DEBUG - Polling http://localhost:29837/status
ERROR - org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
^C/usr/bin/xvfb-run: line 171: kill: (6252) - No such process
尝试创建 Firefox 会话时:
14:30:26.416 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
14:30:26.418 INFO - Found handler: org.openqa.selenium.remote.server.BeginSession@44e7a749
14:30:26.418 INFO - /session: Executing POST on /session (handler: BeginSession)
14:30:26.442 DEBUG - Memory-based payload for: {desiredCapabilities={browserName=firefox}}
14:30:26.453 INFO - Capabilities are: Capabilities {browserName=firefox}
14:30:26.457 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
14:30:26.458 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
1506349826497 geckodriver INFO geckodriver 0.18.0
1506349826501 geckodriver INFO Listening on 127.0.0.1:5611
DEBUG - CookieSpec selected: default
DEBUG - Auth cache not set in the context
DEBUG - Connection request: [route: {}->http://localhost:5611][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
DEBUG - Connection leased: [id: 0][route: {}->http://localhost:5611][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
DEBUG - Opening connection {}->http://localhost:5611
DEBUG - Connecting to localhost/127.0.0.1:5611
DEBUG - Connection established 127.0.0.1:59276<->127.0.0.1:5611
DEBUG - http-outgoing-0: set socket timeout to 10800000
DEBUG - Executing request POST /session HTTP/1.1
DEBUG - Target auth state: UNCHALLENGED
DEBUG - Proxy auth state: UNCHALLENGED
DEBUG - http-outgoing-0 >> POST /session HTTP/1.1
DEBUG - http-outgoing-0 >> Content-Type: application/json; charset=utf-8
DEBUG - http-outgoing-0 >> Content-Length: 49
DEBUG - http-outgoing-0 >> Host: localhost:5611
DEBUG - http-outgoing-0 >> Connection: Keep-Alive
DEBUG - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
DEBUG - http-outgoing-0 >> Accept-Encoding: gzip,deflate
DEBUG - http-outgoing-0 >> "POST /session HTTP/1.1[\r][\n]"
DEBUG - http-outgoing-0 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
DEBUG - http-outgoing-0 >> "Content-Length: 49[\r][\n]"
DEBUG - http-outgoing-0 >> "Host: localhost:5611[\r][\n]"
DEBUG - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
DEBUG - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)[\r][\n]"
DEBUG - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
DEBUG - http-outgoing-0 >> "[\r][\n]"
DEBUG - http-outgoing-0 >> "{"desiredCapabilities":{"browserName":"firefox"}}"
DEBUG - http-outgoing-0 << "HTTP/1.1 500 Internal Server Error[\r][\n]"
DEBUG - http-outgoing-0 << "Connection: close[\r][\n]"
DEBUG - http-outgoing-0 << "Content-Type: application/json; charset=utf-8[\r][\n]"
DEBUG - http-outgoing-0 << "Cache-Control: no-cache[\r][\n]"
DEBUG - http-outgoing-0 << "Content-Length: 1337[\r][\n]"
DEBUG - http-outgoing-0 << "Date: Mon, 25 Sep 2017 14:30:27 GMT[\r][\n]"
DEBUG - http-outgoing-0 << "[\r][\n]"
DEBUG - http-outgoing-0 << "{"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":"stack backtrace:\n 0: 0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d\n 1: 0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0\n 2: 0x44da3d - geckodriver::marionette::MarionetteHandler::create_connection::h6f7058fccafe4367\n 3: 0x425c32 - <webdriver::server::Dispatcher<T, U>>::run::h8f5348b8f5f7c053\n 4: 0x40b22c - std::panicking::try::do_call::hb67c6fb6bcd96195\n 5: 0x5dc20a - panic_unwind::__rust_maybe_catch_panic\n at /checkout/src/libpanic_unwind/lib.rs:98\n 6: 0x41b943 - <F as alloc::boxed::FnBox<A>>::call_box::h4100941edc372034\n 7: 0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>\n at /checkout/src/liballoc/boxed.rs:650\n - std::sys_common::thread::start_thread\n at /checkout/src/libstd/sys_common/thread.rs:21\n - std::sys::imp::thread::{{impl}}::new::thread_start\n at /checkout/src/libstd/sys/unix/thread.rs:84"}}"
DEBUG - http-outgoing-0 << HTTP/1.1 500 Internal Server Error
DEBUG - http-outgoing-0 << Connection: close
DEBUG - http-outgoing-0 << Content-Type: application/json; charset=utf-8
DEBUG - http-outgoing-0 << Cache-Control: no-cache
DEBUG - http-outgoing-0 << Content-Length: 1337
DEBUG - http-outgoing-0 << Date: Mon, 25 Sep 2017 14:30:27 GMT
DEBUG - http-outgoing-0: Close connection
DEBUG - Connection discarded
DEBUG - Connection released: [id: 0][route: {}->http://localhost:5611][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
尝试运行此命令安装最新的稳定版GoogleChrome:
sudo yum -y localinstall google-chrome-stable_current_x86_64.rpm
或
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
我收到此错误:
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgdk-3.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libXss.so.1()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libatk-1.0.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgdk_pixbuf-2.0.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgconf-2.so.4()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: libgtk-3.so.0()(64bit)
Error: Package: google-chrome-stable-61.0.3163.100-1.x86_64 (/google-chrome-stable_current_x86_64)
Requires: xdg-utils
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
有没有人遇到过这个问题并且无论如何都可以解决这个问题?如果您有任何问题,请告诉我。
我无法在 Linux AMI 上安装这些库,但我最终将其安装在 Ubuntu 实例上。这使得使用以下文档的安装非常简单: https://www.npmjs.com/package/selenium-standalone
但是,我的 Ubuntu linux 也收到了一个二进制错误。问题是我的 Linux 机器上没有安装浏览器,但我可以使用此处的说明进行安装: https://askubuntu.com/questions/510056/how-to-install-google-chrome
也适用于 FireFox:
#install firefox browser
sudo apt-get install firefox