What will you learn in this lecture?

In the previous video, we learned how to identify radio buttons using index of this Selenium WebDriver elements identification course. In this video, we’ll have to learn how to use lists using XPath.

How to Use Lists Using XPath

So there’s one other concept, a new concept that I want to bring up for you guys which we have not dealt with before because it was not possible in the IDE. And that is the concept of returning a list of iWeb elements.

So when we put this query into our fire path and hit enter. You guys see what it selects? It selects right the three radio buttons. And that’s good to know because we can have multiple elements returned to our object in Selenium-WebDriver. And using this right here is exactly how we do it.

So we have our locator. And this locator is going to return us three elements. And those elements, rather than being stored in a variable like this, they are now going to be stored in an i-list of iWeb elements, right? An i-list, it’s an interface for a list with a bunch of iWeb element types inside of it. And we’re going to call those elements.

The other thing to notice here is that rather using the find element method that we’ve been using. Here we’re using the find elements because we realize that it’s going to return us multiple elements when we put this in. Let’s run this and take a look at how that object looks once we’re done with it. Excellent!

If I do a step over here, and then scroll up, and we hover over this elements, you guys can see that there are a total count of three elements inside of this i-list.

And if we expand that, you guys can see, just like in our fire path, we can use these brackets to select which element that we want. So for example, if I come over here to the watch, and I do elements, and then put brackets 0, and hit enter, it only looks at the first iWeb element returned from into this i-list.

And you guys, get white zero, right, because in c-sharp a list of any collection is populated from zero index. And in XPath, it starts with one. So just keep that in mind.

But we are populating this c-sharp i-list which starts at zero. And so you can see that this element, the first one can be identified by zero. And if you want to hover over here and expand this and expand that, we can see that this element is tag name input.

And then, if we, for example, want to click it, let me bring this over. By the way, you guys see how this is always checked every time you open a fresh browser. That’s because of that checked property. Checked equals checked.

So if I do this and then I come in here and I can do that click. Oh yeah! That won’t work because you cannot convert it to a group. But what you can do is using these elements.

You can now circle through them and do stuff with them, like click the first one, or click the second one, or check to see if an element contains text using the text property. But it doesn’t have anything because it doesn’t have any text. But so now, you can get this collection and you can work with this collection, and do whatever you need depending on the element that you want.

So this is new but it’s  going to be used throughout a lot of our lectures to help you guys better work with Selenium objects.

[Tweet “Learn everything about elements identification with Selenium Webdriver.”]

Next Tutorial

In the next tutorial, we will cover working with tabs and toggles.

What will you learn in this course?

Are you struggling with working with HTML using Selenium WebDriver? Do you know how to easily identify an element using Selenium WebDrriver? Do you know how to manipulate that web element? Do you know how to perform a drag n’ drop on an element? If not, then these are just a few of the questions that will be answered in this course.

This course is a complete guide on working with web elements in Selenium WebDriver! Once you are finished with this course, you will know how to work with any web elements, any time, on any web application.

“Relevant content that I will be able to apply to my automation tests *immediately*, a VERY effective presentation approach (evolving the same example and comparing/contrasting), and an excellent teacher / presenter. Thank you so much for your time and sharing your knowledge Nikolay!.” 

-Krissy

In this course from Ultimate QA, you will learn:

  • Basics of HTML
  • All the different locator strategies for Selenium WebDriver
  • How to identify web elements using Selenium WebDriver
  • Master XPath
  • Navigation with Selenium WebDriver
  • Web element manipulation
  • Web element interrogation
  • Mouse and keyboard actions with Selenium WebDriver
  • Performing actions such as drag n’ drop, drawing, hovering
  • Implicit and Explicit waits
  • How to properly handle element identification so that your tests are not flaky
  • Expected Conditions in Selenium WebDriver

Take This Entire Course for Free

[Tweet “Learn how to correctly identify elements using #Selenium #Webdriver.”]How