我正在使用 selenium 和 phpunit 来测试我的一些网络内容,但它似乎失败了,即使我可以在失败的屏幕截图中看到我正在测试的文本 - 我的测试在下面列出
<?php
include('setupclass.php');
class AddNewPicStationTest extends setupclass
{
protected function setUp()
{
parent::setUp();
}
public function testMyTestCase()
{
$this->open($this->apppath);
$this->click("css=a > img");
$this->waitForPageToLoad("30000");
$this->type("name=username", "");
$this->type("name=password", "");
$this->click("name=submit");
$this->waitForPageToLoad("30000");
$this->click("link=ADD LIKESTATION");
$this->waitForPageToLoad("30000");
$this->click("link=HOME");
$this->waitForPageToLoad("30000");
$this->click("link=ADD PICSTATION");
$this->waitForPageToLoad("30000");
$this->type("id=title", "Test title 2");
$this->type("id=message", "test description 2");
$this->click("id=tip5");
$this->type("id=album_title", "test album title 2");
$this->type("id=album_description", "test album description 2");
$this->click("//input[@value='Login']");
$this->click("xpath=(//input[@name='group1'])[2]");
$this->type("name=station_pic_upload", "C:\\Users\\chris laptop\\Desktop\\Logo.png");
$this->click("name=g");
$this->waitForPageToLoad("30000");
**$this->assertTrue($this->isTextPresent("Test title 2"),"object created");**
$this->assertFalse($this->isTextPresent("Error"),"Error is present");
$this->assertFalse($this->isTextPresent("Profiler"),"PRofiler is running");
$this->click("link=LOGOUT");
$this->waitForPageToLoad("30000");
}
}
?>
即使屏幕抓取中存在星号行,它也会失败..我是新手,任何帮助都将不胜感激
这是我下面的页面,测试正在寻找-STATION TITLE
<table width="620px" align="left" style="text-align:left;">
<tr style="font-weight:bold;background-color:#f1f1f1">
<td colspan="5" STYLE="text-align:center;font-weight:bold">FACEBOOK PIC STATIONS</td>
</tr>
<tr style="font-weight:bold;background-color:#f1f1f1">
<td width="15%">STATION ID</td>
<td width="50%">STATION TITLE</td>
<td width="10%">STATION STATS</td>
<td width="15%">LAST POST</td>
<td width="10%"></td>
</tr>
<?foreach($picstations->result() as $row){?>
<tr>
<td><?=anchor('socialmedia/edit_picstation/'.$row->station_id,$row->station_id);?> </td>
<td><?=anchor('socialmedia/edit_picstation/'.$row->station_id,$row->title);?> </td>
<td><?=anchor('stats/home/station_stats/'.$row->station_id,'STATS');?> </td>
<td><?=$this->upd8r_date->get_last_post_from_station_time($row->station_id)?></td>
<td><?=anchor('socialmedia/delete/'.$row->station_id,'delete');?></td>
</tr>
<?}?>
</table>
这是我的phpunit输出-
1) AddNewPicStationTest::testMyTestCase
Current URL: http://localhost/upd8r_new/socialmedia/add_picstation
Screenshot: http://localhost/upd8r_new/tests/screenshots/692eb179f8146d2a8491442
68dd2a99a.png
object created
Failed asserting that false is true.
C:\xampplite\php\phpunit:46
FAILURES!
Tests: 1, Assertions: 1, Errors: 1.