Victoria
Victoria

Reputation: 179

Store list of elements matching CSS selector in Selenium IDE variable

I need to run automated tests on whether a Search engine is working correctly on a website - if a keyword is typed, to show only the results containing the specific keyword in their names.

I have to use only Selenium IDE (no WebDriver, no code).

So far, I have managed to define the CSS selectors needed, but do not know how to store an array of elements having this selector.

store text saved the text of the first element of the list (I have checked that the selector is fine by document.querySelectorAll(".ajax_block_product .product-container a.product-name") that gave me 7 elements):

Command: store text

Target: css=.ajax_block_product .product-container a.product-name

Value: array

Maybe I should use the execute script command, but how should I pass the list of elements corresponding to the CSS selector in target then?

As I could not find what command to use to save the texts of these 7 elements in an array that I need to iterate after through, can you please assist here or give some kind of workaround? Thanks!

Upvotes: 1

Views: 1792

Answers (1)

Roslyakova Maria
Roslyakova Maria

Reputation: 446

You should use execute script command to store array like this

Command | Target | Value
execute script | return document.querySelectorAll(".ajax_block_product .product-container a.product-name"); | array

array variable will contain these 7 elements.

Upvotes: 1

Related Questions