问题
Assume xpath as below:
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.
I tried
command target value
store xpath variable1
echo ${variable1}
It displays as variable1: xpath. But i need variable1: 'Displaying 1 to 30 of 145300'. Can anyone help me please ?
回答1:
Try storeText ( locator, variableName )
Then use it ${variableName}
Refer Selenium documentation for storeText
回答2:
saga told you how to store that string, as you need to store only 145300, below code will help you
store | Displaying 1 to 30 of 145300 | string
store | 1 | delimiter
store | javascript{storedVars['string'].split('of')[storedVars['delimiter']]} | result
echo | ${result}
来源:https://stackoverflow.com/questions/11010992/how-to-store-the-content-value-of-xpath