Bob
Bob

Reputation: 21

Append text to an existing field that contains text

I am trying to add text into a field that already contains text without clearing the existing text. Append the text essentially

The 'input text' keyword clears the field before each iteration so is not a viable solution

Does anyone know of a way to do this?

Upvotes: 1

Views: 1859

Answers (2)

Richard Zilahi
Richard Zilahi

Reputation: 692

I recommend to use javascript, by calling Execute Javascript keyword from Selenium2Library as the following:

Execute Javascript $("#inputfield").val($("#inputfield").val() + " some more text");

Upvotes: 0

shicky
shicky

Reputation: 2126

Why don't you simply use Get Text to retrieve what the field contains already, assign it to a variable, then use input text to add whatever you want. i.e

${original_text}=    Get Text    Input_Field_Locator
Input Text    Input_Field_Locator    ${original_text}+${append_text}

Upvotes: 2

Related Questions