Forem

Cover image for Find Multiple Elements | Selenium Python Tutorial
Dilpreet Johal
Dilpreet Johal

Posted on

4 2

Find Multiple Elements | Selenium Python Tutorial

During browser automation, you’ll often run into scenarios where you will need to work with multiple elements such as when dealing with menu links lists, dropdown lists, etc… In this tutorial, we will cover how to find multiple elements in Selenium Python using the SeleniumBase framework.

Test Scenario

Get the text of all the menu link items below and assert the value.

test_scanario

Test Solution

Since we are working with multiple menu links, we will need to loop through all the list items. However, before that, we need to get access to all the elements first and we can do that using the find_elements method.

Code1

Once, we have access to all the elements, we can do a regular for loop and assert the value of the elements.

Code2


Check out the video below to learn how to work with multiple elements in Selenium Python –


📧 Subscribe to my mailing list to get access to more content like this

👍 Follow automationbro on Twitter for the latest updates

...

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

You can also support me by liking and sharing this content.

Thanks for reading!

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay