2013-03-28 19 views
0

所以正如標題所說,當我使用verifyElement並通過ID搜索時,測試不會崩潰。但是當我嘗試輸入數據(特別是文本框)時,測試失敗。Selenium能夠驗證元素,無法訪問/使用這些元素

文本框:

<span><input type="text" name="searchString" maxlength="100" value="" id="searchString" class="commonTextBox"></span> 

這並不失敗:

automation.verifyElement(AutomationConstants.FIND_ID, "searchString", false); 

這種失敗:

automation.enterInputBox(AutomationConstants.FIND_XPATH, "//input[@id='searchString'and @class='commonTextBox']", "Alex", false); 

我也用FIND_ID代替XPATH,這也將失敗。

我出來的想法。

+0

只需在firebug中驗證在同一個定位器中有多少個元素。 – Santoshsarma

+0

不幸的是,我不能訪問除IE以外的任何頁面。 – thisisnotabus

+0

:(。使用driver.findElements(By).size()來計算出在同一個定位器中有多少個元素。 – Santoshsarma

回答

0

測試不會在驗證時崩潰。您應該使用Assert而不是Verify。在這種情況下,您將確定該元素確實包含您所需的內容。

0
driver.findElement(By.xpath("//input[@id='searchString'and @class='commonTextBox']")).sendKeys("YOUR TEXT");