Codeception-如何处理具有非唯一名称的字段


Codeception - How to address a field with non-unique name

我想用代码感知测试一个记录列表。我有一个表单,有像这个这样的独特行

<tr id="row1">
  <td class="description">
    <input name="description" type="text" value="some text">
  </td>
</tr>
<tr id="row2">
  <td class="description">
    <input name="description" type="text" value="some more text">
  </td>
</tr>

因此字段的名称是相同的,而行的id则不同。当我尝试时

$I->fillField("#row1 input[name='description']", "some other text");

失败

Field by name, label, CSS or XPath '#row1 input[name="description"]' was not found on page.

我相信答案就在眼前,但我正在努力寻找。有什么提示或想法吗?

Thanx,

m!

您可以使用CSS选择器td:nth child(1)td:nth of child(2)

还要注意(IRC)PHPBrowser只能在表单中包含的字段上使用fillField。

您可以尝试与xpath一起使用,如:

$I->fillField("//*[@id='row1']//input","Input text here");

如果你真的想玩CSS,你可以试试下面的代码:

$I->fillField("#row1 input","Input text here");