Запустить сервер Selenium с помощью webdriver

100
14

~/tests> uname -a Linux ghopper-K52F 4.10.0-40-generiС# 44-Ubuntu SMP Чт ноя 9 14:49:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

~/tests > ls -al
total 37404
drwxrwxr-x 2 ghopper ghopper 4096 ноя 23 22:05 .
drwxr-xr-x 33 ghopper ghopper 4096 ноя 24 10:53 ..
-rwxr-xr-x 1 ghopper ghopper 8799120 ноя 23 10:51 chromedriver
-rwxrwxr-x 1 ghopper ghopper 7194178 окт 31 22:15 geckodriver
-rw-rw-r-- 1 ghopper ghopper 22234765 ноя 23 10:52 selenium-server-standalone-3.7.1.jar

~/tests > apt list --installed | grep openjdk

openjdk-9-jre-headless/zesty,now 9~b161-1 amd64 [installed]

Я хочу запустить сервер с chromedriver

~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar 
2017-11-24 11:12:16.560:INFO::main: Logging initialized @3822ms to org.seleniumhq.jetty9.util.log.StdErrLog
2017-11-24 11:12:18.501:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 11:12:18.577:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@58a9760d{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 11:12:18.587:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@58a9760d{/,null,AVAILABLE}
2017-11-24 11:12:18.662:INFO:osjs.AbstractConnector:main: Started ServerConnector@66a17408{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 11:12:18.663:INFO:osjs.Server:main: Started @5924ms

Как мы видим, нет никаких упоминаний о webdriver. Все мои тесты были неудачными, и браузер не запускался вообще. Я получил фрагмент журнала на консоли сервера:

Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 8315
Only local connections are allowed.

И проблема проверки:

./vendor/bin/phpunit -v -c tests/phpunit.xml tests/src/Selenium/LoginTest.php
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Runtime: PHP 7.0.22-0ubuntu0.17.04.1
Configuration: /home/ghopper/work/***/tests/phpunit.xml

ESSSS

Time: 12.19 seconds, Memory: 6.00MB

There was 1 error:

1) Package\Test\Selenium\LoginTest::testUnauthorizedRandomPage
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:

/home/ghopper/work/***/vendor/phpunit/phpunit selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:71
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Isolated.php:67
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Shared.php:79
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:246
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:287
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:264

--

There were 4 skipped tests:
...

Вопросы:

Почему Selenium работает без webdriver. Как отлаживать сервер? Где ошибка и ее причина? Как проверить java и его среду?

PS Я делаю то же самое на другом ПК, и все работает отлично для меня. Я думаю, проблема в среде, а не в конфигурации сервера.

спросил(а) 2021-01-25T15:09:27+03:00 4 месяца, 4 недели назад
1
Решение
88

~/tests > sudo apt-get purge openjdk-9-jre-headless
~/tests > sudo apt install openjdk-8-jre-headless
~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
12:48:44.839 INFO - Selenium build info: version: '3.7.1', revision: '8a0099a'
12:48:44.841 INFO - Launching a standalone Selenium Server
2017-11-24 12:48:44.885:INFO::main: Logging initialized @534ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:48:45.006 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:48:45.099 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.099 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.100 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
12:48:45.226 INFO - Using the passthrough mode handler
2017-11-24 12:48:45.280:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 12:48:45.347:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@30a3107a{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 12:48:45.365:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@30a3107a{/,null,AVAILABLE}
2017-11-24 12:48:45.414:INFO:osjs.AbstractConnector:main: Started ServerConnector@56c57463{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 12:48:45.414:INFO:osjs.Server:main: Started @1063ms
12:48:45.414 INFO - Selenium Server is up and running

Теперь все работает отлично! Спасибо )

ответил(а) 2021-01-25T15:09:27+03:00 4 месяца, 4 недели назад
Ваш ответ
Введите минимум 50 символов
Чтобы , пожалуйста,
Выберите тему жалобы:

Другая проблема