当前位置: 首页 > 知识库问答 >
问题:

使用webdriver运行Selenium服务器

佘俊茂
2023-03-14

~/tests>uname-a Linux ghopper-K52F 4.10.0-40-generic#44-Ubuntu SMP Thu 11月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
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:
...
    null

附言。我在另一台电脑上做同样的事情,对我来说一切都很好。我认为问题出在环境上,而不是服务器的配置上。

共有1个答案

劳法
2023-03-14
~/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

现在一切都很好!谢谢)

 类似资料:
  • 我正在尝试在一个使用chrome的Linux服务器上运行一个使用selenium webdriver实现的测试,并且不显示我的java代码 要运行此程序(jar),请使用以下命令启动Xvfb 当我运行程序时,经过一段长时间的等待,我得到了这个异常 当我尝试单独运行chrome时,a遇到了这个问题 问题是: 是在定位驱动程序的问题还是在chrome或我需要一些额外的配置?

  • 我目前正在尝试使用Selenium WebDriver(JAVA)2.53和Firefox 43.0执行TOR 6.0.4。我已经按照这篇文章的说明使用Selenium WebDriver和Tor,但在将Tor的profilePath加载到Firefox二进制文件时,我遇到了一个错误。我已经看到可以通过加载TOR配置文件来访问TOR。firefox二进制文件的默认存档,但我得到了一个驱动程序信息:

  • 问题内容: 我正在使用Selenium 2 WebDriver。由于以下原因,我从网站启动了它而不是UnitTest项目: 它应该每24小时自动运行一次。我已经使用System.Threading编写了一些调度代码。 提供一些用户界面,以便客户在需要时进行中间运行。 每次运行时,都会将电子邮件作为测试结果的一部分发送。 我的目标网站是:http : //www.vroomvroomvroom.co

  • 我写了这样的代码,但是这段代码没有运行chromedriver,我已经添加了文件(chromedriver.exe)和这个路径(\chromedrive\chromedriver.exe)。 . . 错误消息是: JAVAlang.Exception初始化错误 原因:java。lang.IllegalStateException:驱动程序可执行文件的路径必须由webdriver设置。铬。驱动系统属

  • 我正在使用testNG框架和ANT任务运行Selenium测试。测试在我的windows机器上运行良好。。然后,我将其部署到我的Jenkins CI服务器上,并为无头运行测试进行必要的配置: > 在运行jenkins(CentOS)的服务器上安装了vnc服务器 为jenkins安装了Xvnc插件,并在我的作业配置中启用了“在构建期间运行Xvnc” 然而,我得到以下错误-任何帮助?我已经搜索了网络,

  • 问题内容: 我一直在使用selenium在python中自动进行浏览器模拟和Web抓取,对我来说效果很好。但是现在,我必须在代理服务器后运行它。现在,selenium打开了窗口,但是由于未在打开的浏览器中设置代理设置而无法打开请求的页面。当前代码如下(示例): 如何更改上面的代码以立即与代理服务器一起使用? 问题答案: 您需要设置所需的功能或浏览器配置文件,如下所示: