1

我希望有人能帮助我,因为我真的正要在这张桌子上撞我的桌子:-(

我正在尝试让 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.

我显然遗漏了一些非常明显的东西,但是花了几个小时在论坛上拖网并没有找到任何可以解决它的东西,我需要帮助!

4

2 回答 2

1

使用属性选择器通过其名称属性选择输入元素:

$I->fillField('input[name=search]', 'def');
于 2014-05-19T13:15:08.857 回答
0

为该字段分配一个 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');

我希望这项工作。

于 2014-04-02T08:37:16.780 回答