I'm trying to store text within an element. This text is dynamically generated. Is there a way to store text within an element using watir webdriver and then paste it into another element?
From all the research I have done, this is what I have come up with but do not know the command to paste the text within another element.
@browser.element(:css => 'div.confirmationMessage > span').text
I have had similar scenario where I have to upload a case and the case id is randomly generated which has to be verified the next page
In this case You store it in a variable and if you want the text to be pasted on an other field, just call this field n the element in send_keys
tostoretext = @browser.element(css: 'div.confirmationMessage > span').text
@browser.element(id: 'elementidentifier').send_keys(tostoretext)
if you want to call this outside of your function, make it accessibile with @
If you are using cucumber function for this, give the gherkin as:
Then I enter the text in identifier "elementidentifier" generated in identifier "div.confirmationMessage"
With the above gherkin, this is accessible within that cucumber function itself. Ensure the identifiers are correctly accessible.