我刚刚开始在PHPUnit中使用Selenium-RC,以便执行一些基于web的测试。最初,我在Windows7上使用了这个指南-- http://jodyt.com/2009/03/selenium-rc-and-php/ --它运行得很好。
我可以创建一个.php文件测试并用phpunit运行它。
但是,我被要求在Ubuntu 8.04上本地运行这个程序。因此,我下载selenium-rc服务器并将其解压缩到~/selenium,它可以通过发出'java -jar selenium-server.jar‘正常工作。
现在,当我将目录更改为我的php测试文件所在的位置时,从运行selenium-server的窗口中得到以下错误:
15:26:58.317 INFO - Got result: ERROR Server Exception: sessionId led to start
new browser session: Error while launching browser doesn't exist; perhaps this
session was already stopped? on session led to start new browser session:
Error while launching browser
15:26:58.323 INFO - Command request: testComplete[, ] on session led to start
new browser session: Error while launching browser
15:26:58.323 INFO - Got result: OK on session led to start new browser
session: Error while launching browser我正在尝试通过Putty连接到Ubuntu机器并打开X11转发来完成所有这些工作。
你知道哪里出问题了吗?
发布于 2010-01-21 19:45:06
解决了。已安装较新版本的Java。感谢访问此页面- http://clearspace.openqa.org/thread/14502
发布于 2010-01-21 00:58:45
好的。
<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class SomeTest extends PHPUnit_Extensions_SeleniumTestCase
{
private $licence;
function setUp()
{
$this->setBrowser('*firefox');
$this->setBrowserUrl("http://blah");
}
function getLicence()
{
return $this->licence;
}
function setLicence($licence)
{
$this->licence = $licence;
}
function isStarted($element)
{
return $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/started.gif']");
}
function isStopped($element)
{
return $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/stopped.gif']");
}
function isDisabled($element)
{
return $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/disabled.gif']");
}
function testStatusPage()
{
$this->open("/blah/");
//
$this->setLicence('NA');
//
$this->assertEquals($this->getLicence(), $this->getText("//div[@id='S1']/fieldset[1]/dl/dd"));
// Verify certain services are running
$this->assertTrue($this->isStarted('a'));
$this->assertTrue($this->isStarted('b'));
$this->assertTrue($this->isDisabled('c'));
$this->assertTrue($this->isDisabled('d'));
$this->assertTrue($this->isStopped('e'));
$this->assertTrue($this->isStarted('f'));
$this->assertTrue($this->isStarted('g'));
$this->assertTrue($this->isStarted('h'));
$this->assertTrue($this->isStarted('i'));
}
}
?>很抱歉我的格式化。我还创建了一个更简单的,它刚刚检查了谷歌首页的标题是‘谷歌’,它只是说
Fatal error: Call to undefined method SimpleTest::assertTitle()所以我认为它没有正确地找到头文件,但我做了一个'find‘,它是在
/usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php我完全迷路了。
https://stackoverflow.com/questions/2102629
复制相似问题