Jackie James
Jackie James

Reputation: 853

How to store the content/value of xpath?

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 ?

Upvotes: 4

Views: 14796

Answers (2)

Rohit Ware
Rohit Ware

Reputation: 2002

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}

Upvotes: 2

sagaofsilence
sagaofsilence

Reputation: 139

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

Refer Selenium documentation for storeText

Upvotes: 3

Related Questions