Kieran M
Kieran M

Reputation: 461

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.

Upvotes: -1

Views: 40

Answers (1)

Anand Gautam
Anand Gautam

Reputation: 2101

Let's assume the xpath is as below:

//input[@name = 'name']

Then to get element attribute

${GET_ATTR_ELE}   Get 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}

Hope this helps!

Upvotes: 0

Related Questions