storeText (target, pattern) - Selenium IDE command

The storeText command in the Selenium IDE software testing tool is useful to store the text value of page element in to variable for future use. So it the recommended command for web scraping information from HTML text and tables. Update V5.3.3: If the locator is not found, no error is trigged. Instead, the text #LNF is stored in the variable. "#LNF" stands for "Locator not found".

Note that for input boxes, select boxes, checkboxes, radiobuttons or textareas the text that you see is technically the field value. So storeText does not work on these elements by design, it returns "". Instead, use storeValue to extract text from input elements.

If you need the extract text from the HTML source code directly use sourceExtract.

For more information about data extraction in general see Web Scraping with Selenium IDE.

Extracting JSON

A web api (e. g. OCR Api) displays JSON in the browser, not HTML. Ui.Vision has no special "store Json" command, but that is not needed. You can simply use storeText with locator css=Pre to extract the JSON. To access a certain JSON element parse this raw JSON data with executeScript_Sandbox with "JSON.parse". => We have a demo macro here: JSON scraping with RPA.

Screencast: Web scraping with storeText:

Jump to the end of the video to see the extracted data in the CSV file. The related forum post is Web scraping with Kantu.

storeText Example

Command Target Pattern/Text
open https://ui.vision/
storeText //*[@id="content"]/div[2]/div/h2[1] name
echo Name var = ${name}

Works in

Ui.Vision RPA for Chrome Selenium IDE, Ui.Vision RPA for Firefox Selenium IDE, Firefox IDE Classic

Related Demo Macros

DemoStoreEval

The ready-to-import-and-run source code of all demo macros can be found in the Open-Source RPA software Github repository.

Related commands: storeTextPresent, verifyTextPresent

The "storeTextPresent" command is not for storing value of any target element, but could be used to verify that specified target text is available on the page or not. The Ui.Vision RPA IDE does not support storeTextPresent (and verifyTextPresent) because we want to help reduce the zoo of previous IDE commands.

In the modern Ui.Vision RPA IDE storeTextPresent and verifyTextPresent can be easily recreated with storeText plus if (${var} == "text to check"). The table below shows an example: It "simulates" storeTextPresent by using storeText and then checks the variable if the text is correct. If not, it throws an error.

Command Target Pattern/Text
open https://ui.vision/demo/storetext
storeText css=#content > div.row > div > h2:nth-child(4) myvar
if ${myvar}.includes("Catch") == true
throwError text found on website!
end

See also

Parse Text, Check for substring, Split string, Wildcards in Selenium IDE locators, storeTitle, Web Automation Extension User Manual, Selenium IDE commands, Classic Firefox Selenium IDE.

Anything wrong or missing on this page? Suggestions?

...then please contact us.

<em>Ui.Vision RPA</em> Selenium IDE for Chrome and Firefox - Web Test Automation

Fresh from the Ui.Vision Forum: The Latest 3 Topics. Join the discussions:

← Meet the Ui.Vision team and users in our forums.