我希望有人能帮助我,因为我真的快要把我的桌子撞到这个桌子上了:-(
我试图让 fillFIeld 工作,但我似乎无法让它屈服。
seeInField在相同的表单字段上工作,所以我认为我的定位等都很好。
我什至写了一个令人难以置信的基本测试来尝试其他所有规则。
该 HTML ...
<!DOCTYPE html>
<html>
<body>
<form id="SearchForm" action="" method="get">
<input type="text" name="search" value="abc" />
<button type="submit">Search</button>
</form>
</body>
</html>
测试...
//INSTANTIATE WEB GUY
$I = new WebGuy($scenario);
//DEFINE TEST
$I->wantTo('search from home');
//GET ON THE HOME PAGE
$I->amOnPage('/');
$I->seeInField('search', 'abc');
$I->fillField('search', 'def');
$I->seeInField('search', 'def');
输出...
Acceptance Tests (1) ---------------------------------------------------------------------------------------
Modules: PhpBrowser, WebHelper
------------------------------------------------------------------------------------------------------------
Trying to search from home (Search_From_Home_Page_Cept.php)
Scenario:
* I am on page "/__staging/"
* I see in field "search","abc"
* I fill field "search","def"
* I see in field "search","def"
FAIL
------------------------------------------------------------------------------------------------------------
Time: 25 ms, Memory: 12.25Mb
There was 1 failure:
---------
1) Failed to search from home in Search_From_Home_Page_Cept.php
Sorry, I couldn't see in field "search","def":
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'def'
+'abc'
Scenario Steps:
4. I see in field "search","def"
3. I fill field "search","def"
2. I see in field "search","abc"
1. I am on page "/__staging/"
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
我显然错过了一些非常明显的东西,但是花了几个小时拖网论坛,没有找到任何解决它的东西,我需要帮助!
使用属性选择器通过名称属性选择输入元素:
$I->fillField('input[name=search]', 'def');
为字段分配一个 ID。
<input type="text" id="search_input" name="search" value="abc" />
$I->seeInField('#search_input', 'abc');
$I->fillField('#search_input', 'def');
$I->seeInField('#search_input', 'def');
我希望这项工作。