微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Selenium服务器 – PHPUnit无法连接

我试着为PHP Unit& amp; Selenium服务器.
我有一个难以置信的问题,我不知道为什么.

我使用的是最新的Selenium stand服务器2.42.2.当我运行服务器时,它显示

root@test:/home/jakub# java -jar /usr/local/bin/selenium-server-standalone-2.42.2.jar
Jun 30, 2014 4:32:53 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
16:32:53.398 INFO - Java: Oracle Corporation 24.51-b03
16:32:53.399 INFO - OS: Linux 3.12-1-amd64 amd64
16:32:53.413 INFO - v2.42.2, with Core v2.42.2. Built from revision 6a6995d
16:32:53.508 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver 
registration is skipped: registration capabilities Capabilities [{platform=WINDOWS,  
ensureCleanSession=true, browserName=internet explorer, version=}] does not match
with    
current platform: LINUX
16:32:53.563 INFO - RemoteWebDriver instances should connect to: 
http://test.jacon.cz:4444/wd/hub
16:32:53.564 INFO - Version Jetty/5.1.x
16:32:53.565 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
16:32:53.566 INFO - Started HttpContext[/selenium-server,/selenium-server]
16:32:53.566 INFO - Started HttpContext[/,/]
16:34:07.013 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@7cbae009
16:34:07.014 INFO - Started HttpContext[/wd,/wd]
16:34:07.022 INFO - Started SocketListener on 0.0.0.0:4444
16:34:07.023 INFO - Started org.openqa.jetty.jetty.Server@17056563

似乎Selenium服务器正常运行.但是当我尝试在PHP中运行简单测试时,使用PHPUnit,它说它无法连接到Selenium服务器.

root@test:/home/jakub# /usr/local/bin/PHPunit --verbose sel.PHP
PHPUnit 4.1.3 by Sebastian Bergmann.

SS

Time: 73 ms, Memory: 3.25Mb

There were 2 skipped tests:

1) loginTest::testLoginTrue
The Selenium Server is not active on host http://test.jacon.cz at port 4444.

2) loginTest::testLoginFalse
The Selenium Server is not active on host http://test.jacon.cz at port 4444.

OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 0, Skipped: 2.

我通过netstat -apn检查了如果Selenium服务器正在侦听端口4444并且它正在侦听,则为grep 4444.有人知道如何解决这个问题吗?我用Google搜索,但没有任何结果.

顺便说一下.这是PHP中测试的代码

<?PHP
class loginTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected $captureScreenshotsOnFailure = TRUE;
protected $screenshotsPath = '';
    protected $screenshotsUrl = '';

protected function SetUp()
  {
  $this->setbrowser('chrome');
  $this->setbrowserUrl('http://test.jacon.cz/');
  //$this->setPort(4444);
  //$this->setTimeout(2);
  $this->setHost("http://test.jacon.cz");
}

public function testLoginTrue()
  {
      $this->url('/sms');
  $this->byName('username')->value('Kristyna');
  $this->byName('password')->value('*****');
  $this->byCssSelector('form')->submit();
      $url = $this->url();
  $this->assertEquals('Statistics', $this->title(), 'Přihlášení neproběhlo');
  $this->assertStringEndsWith('sms/', $this->url(), 'Přihlášení neproběhlo');
  }

     public function testLoginFalse()
  {
  $this->url('/sms');
  $this->byName('username')->value('abcdefgh');
  $this->byName('password')->value('123456');
  $this->byCssSelector('form')->submit();
      $url = $this->title();
  $this->assertEquals('Login to SM', $this->title(), 'Přihlášení proběhlo');
  }
}
?>

希望你能帮忙.谢谢.

解决方法:

我一直在做类似的事情,但是在Python中.但我没有必要运行Selenium服务器.我所要做的只是下载selenium模块,我很高兴.也许在PHP中可能是相同的?我真的不知道服务器会是什么,你需要的只是模拟浏览器的驱动程序,还是Python本身在某个地方运行服务器?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐