What will you learn in this lecture?
In the previous video, we learned how to figure out if an element contains some text of this Selenium web driver elements identification course. In this video, we’ll have to learn how to identify link and icon using XPath.
How to Identify Link and Icon Using XPath
Now, let’s analyze a link.
Come over here and hover over this link. And what you can see right away as that fire path gives me this XPath which is pretty excellent because we have an ID. An ID, like I said, it’s always the best because it means that the element is unique. So we can use Selenium web driver to do by that ID.
And just supply this value. That’s right there! You can also use our favorite “contains” text function. And again it’s not my favorite here because it’s too long for our purposes.
This has an ID, might as well just use it. But if we wanted to, we just put that in here and then we hit enter. And you guys see, still identifies this link. And then obviously you can do by XPath and just pass in the exact string that our original fire path query displayed, which is this.
And looking at all of these again, you can see that the most simple one is ID. So you just do by that ID. And then you just supply the value. Like that. And that’s it you don’t have to try to figure out an XPath if you got an ID. Take it next.
Let’s talk about an icon.
Have you guys worked with icons before? If you have and you’ve had trouble, now, you will learn how to do it. So looking at this clickable icon, this is the initial have that is given to me. So I’ll put that here.
What else can we do here? Well, we see this has a class, right? So let’s try using the class. So how do we do that? Remember class is an attribute. So if we get rid of all this and we don’t care what tag it is. That’s why there’s that star there.
But we do care that it’s a class and that it has a value of this guy. And then we hit enter. And it still maintains the question, “Is anything else have a class like this in here?” I don’t think so.
And so we can do that, use this and obviously you can do that by the class name. And then just pass in the value.
And again that is what I would probably use just because it’s the most simple and you don’t really have to do too much extra work.
[Tweet “Learn everything about elements identification with Selenium Webdriver.”]
In the next tutorial, we will cover how to identify fields using XPath.
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!.”
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