如何存储xpath的内容/值?

时间:2012-06-13 08:31:49

标签: xpath selenium-ide

假设xpath如下:

xpath : //div[@id='cslGridViewPanelControl']/div/div[2]/div/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td/div

Last div element contains 'Displaying 1 to 30 of 145300'.
I need to store 'Displaying 1 to 30 of 145300' in some variable by using selenium tool.

我试过

command    target           value 
 store      xpath           variable1
 echo      ${variable1}

显示为variable1:xpath。但我需要变量1:'显示1到30的145300'。 有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:3)

Try storeText ( locator, variableName )
Then use it ${variableName}

请参阅Selenium documentation了解storeText

答案 1 :(得分:2)

saga告诉你如何存储该字符串,因为你需要只存储145300,下面的代码会帮助你

store   |  Displaying 1 to 30 of 145300  |  string
store   | 1 |  delimiter
store   | javascript{storedVars['string'].split('of')[storedVars['delimiter']]}  |  result
echo    | ${result}