How to store the content/value of xpath?

ぃ、小莉子 提交于 2019-12-07 07:14:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!