storeAttribute - Selenium IDE
storeAttribute (locator@attribute, variable) - Selenium IDE command
The storeAttribute stores the attribute value of specified element into a given variable. You can store any attribute's value using the "storeAttribute" command. The input is the usual locator for the element followed by an @ sign and then the name of the attribute in target column of selenium IDE. For example css=img.responsive-img@src Here "css=img.responsive-img" is element's locator and "src" is attribute name which we want to store (in this case this is the link).
storeAttribute does not work with input boxes. But for this, you can use executeScript | window.document.getElementsByName('Phone')[0].value; | value as replacement. This does the same as storeValue in the old IDE.
Note that for all store... commands no error is trigged if the locator is not found. Instead, the text #LNF is stored in the variable. "#LNF" stands for "Locator not found".
Related forum post(s): What attributes can be used with store Attribute?, How to copy and paste mp3 hyperlink and Extraction from web page and saving in csv element .
For more information about data extraction in general see Web Scraping with Selenium IDE.
storeAttribute Example
The example extracts the link and the ALT text from an image.
Command | Target | Pattern/Text |
---|---|---|
open | https://ui.vision/rpa/docs/selenium-ide/executescript | |
storeAttribute | css=img.responsive-img@src | myimagelink |
storeAttribute | css=img.responsive-img@alt | myimagetext |
storeAttribute | linkText=flow control commands@href | mytextlink |
echo | The image links to ${myimagelink} and its ALT text is ${myalttext} |
Works in
Ui.Vision RPA for Chrome Selenium IDE, Ui.Vision RPA for Firefox Selenium IDE, Firefox IDE Classic
Related Demo Macros
DemoExtract
The ready-to-import-and-run source code of all demo macros can be found in the Open-Source RPA software Github repository.
See also
storeEval, storeText, 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.