Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I capture the value of 'value' attribute and save it as a variable?

I would like to capture the value of an input element and save it as a string variable in Robot Framework. How would I do this?

The element structure is as follows:

<input name="name" class="input" type="text" value="Default Text">

I would like to capture the "Default Text" value and save it in a string using Robot Framework and Browser Library.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Let’s assume the xpath is as below:

//input[@name = 'name']

Then to get element attribute

${GET_ATTR_ELE}   Get Element Attribute     //input[@name = 'name']   value

where ${GET_ATTR_ELE} is the variable.
Then set the variable to use it later

Set Test Variable    ${GET_ATTR_ELE}

Note: You must import SeleniumLibrary.
Hope this helps!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading