測試頁的選項卡順序我想測試我的網頁上我的輸入字段的Tab鍵順序,我想我可以使它看起來像這樣:我可以用PHPUnit_Extensions_Selenium2
#get the number of inputs on the page
$input = $this->elements($this->using('css selector')->value('div.wrapper input'));
for ($i=1; $i <= count($input); $i++)
{
#just to set focus on the field i know is the first
if($i == 1)
{
$this->byId('myFirstField')->value($i);
}
else
{
$this->keysSpecial('TAB');
$this->get current element in focus->value($i);
}
}
然後我就可以無論是坐在那裏,看到的數字寫在正確的順序或完全自動化,並斷言值是像這樣每場正確:
$this->assertEquals($this->byId('myFirstField')->value(), 1);
$this->assertEquals($this->byId('mySecondField')->value(), 2);
等等,但你可以SE這個代碼不會工作,我不知道如何告訴phpunit在當前輸入字段中鍵入內容。有沒有一種調用焦點元素的方法?即$ this-> inFocus() - > value($ i); ?
和btw我不能使用$ input [$ i-1] - > value($ i);因爲標籤順序和字段的索引不會相同。