2016-08-22 137 views
1

如何使用Selenium IDE獲取給定表格的行數?Selenium IDE:獲取表格中的行數

當我右鍵單擊我的表,我只能斷言/驗證以下內容:

  • 標題
  • 價值
  • 文本
  • 元現

與目標是

//div[@id='reports']/div[n]` where `n` is the number of rows. 
+0

你有沒有試過這個:http://stackoverflow.com/questions/19155430/selenium-how-to-count-the-number-of-rows-in-a-table –

+0

@ThiagoCustodio我做了,兩個答案有無關緊要的。一個是Selenium WebDriver,另一個或者過時或者不正確。雖然我只是想出了一個解決方案 – 8protons

回答

0

要使用storeXpathCount命令。這需要其可以在以下參數,分別被存儲在IDE TargetValue字段內的兩個參數:

  • 的xpath:XPath表達式來評估
  • VARIABLENAME

這裏是一個例子,其中表id = reports

Command: storeXpathCount 
Target: //div[@id='reports']/div[n]/table/tbody/tr 
Value: myVarCount 

其中ndiv[n]從上面是您的div編號。

提示:用Selenium IDE打開你的桌面,右鍵點擊你的桌面,快速找到路徑!