Working with Multiple Elements in Selenide

In this Selenide tutorial series post, we will learn how to work with multiple elements using the $$ sign.

$$ (css selector)

When working with individual element in Selenide, we use $ sign which returns us a single element back. To work wit…


This content originally appeared on DEV Community and was authored by Dilpreet Johal

In this Selenide tutorial series post, we will learn how to work with multiple elements using the $$ sign.

$$ (css selector)

When working with individual element in Selenide, we use $ sign which returns us a single element back. To work with multiple elements we need to use $$ sign to get Elements Collection returned. Let’s take a look at an example –

ElementsCollection linkLists = $$("#primary-menu li[id*=menu-item]");

The above code will return all the elements matching the css selector as a collection of elements. You can then use this to iterate through the elements or get the text and so on..

$$ (By)

By default $$ uses a css selector but you do have an option to provide any other selector as well such as XPath, name etc..

ElementsCollection linkLists = $$(By.xpath("//li[starts-with(@id, \"menu-item\")]"));

To learn more about working with multiple elements in Selenide, check out the video below –

📧 Subscribe to my mailing list to get access to more content like this as well as be part of amazing free giveaways.

👍 You can follow my content here as well -

...

I love coffees! And, if this post helped you out and you would like to support my work, you can do that by clicking on the button below and buying me a cup of coffee -

Buy me a coffee


This content originally appeared on DEV Community and was authored by Dilpreet Johal


Print Share Comment Cite Upload Translate Updates
APA

Dilpreet Johal | Sciencx (2022-07-25T12:19:37+00:00) Working with Multiple Elements in Selenide. Retrieved from https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/

MLA
" » Working with Multiple Elements in Selenide." Dilpreet Johal | Sciencx - Monday July 25, 2022, https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/
HARVARD
Dilpreet Johal | Sciencx Monday July 25, 2022 » Working with Multiple Elements in Selenide., viewed ,<https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/>
VANCOUVER
Dilpreet Johal | Sciencx - » Working with Multiple Elements in Selenide. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/
CHICAGO
" » Working with Multiple Elements in Selenide." Dilpreet Johal | Sciencx - Accessed . https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/
IEEE
" » Working with Multiple Elements in Selenide." Dilpreet Johal | Sciencx [Online]. Available: https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/. [Accessed: ]
rf:citation
» Working with Multiple Elements in Selenide | Dilpreet Johal | Sciencx | https://www.scien.cx/2022/07/25/working-with-multiple-elements-in-selenide/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.