What will you learn in this course?
Are you struggling with working with HTML using Selenium WebDriver? Do you know how to easily identify and manipulate an element using Selenium WebDriver? How about performing 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, anytime, on any web application.
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
What will you learn in this lecture?
In this video, we will go through how to use absolute Xpath to identify an element in Selenim of the Elements Identification course.
Selenium Tutorial – How to Use Absolute Xpath to Identify an Element in Selenium
All right my friend. So let’s talk about the next identifier that we’re going to use to locate our web elements. And that’s called X path X path is a very phenomenal way that we’re going to locate our elements because it helps us to locate the elements even when there are no unique properties. I mean there are almost always unique properties but a lot of times using something simple like link text or non-ID or a name is not possible. And so that’s when we use XPath to dig down to the element exactly that we want the standard definition for X path is that it’s a standard navigation tool for X somehow. However X somehow and HTL are very similar. For those of
For those of you that know what X-amount looks like and you guys will just loanword HDMI it looks like and basically X-amount looks exactly the same except for X somehow was developed to convey data and HCM L was developed to display data. So kind of a different purpose of each one but they’re both structurally very similar or in fact almost the same minus a few key differences. So if you look at a standard HVM Now that’s what X somehow looks like. But anyways because of that those similar structures we can’t navigate HDMI all using X path. So let me show you guys some examples.
Let’s pull up our friendly Kooch speech Tauriel that slash automation practice page and then I’m going to come over here grab this highlighting tool and I can hover over this button and rather than using She asserts here I’m going to select X path or highlight again and you guys can see here that this is the X path that was provided to me by the tool when I highlighted the PS. and this is the path that was given. And now this X path you can see it’s pretty long right so what it does is it digs down into each of these sections until we get to the right place. So, for example, it starts with this id post. So that comes up all the way up to here. Right.
So then it takes the next child and comes in here and then and there and then inside of here and see how it keeps getting the area keeps getting smaller and then inside of that area is something else and then inside of that area is something else and then inside of this area is a button and inside of that is finally our Click the link that we want to click upon. So this is what’s called a relative X path but it’s a very long relative X path an absolute X path would actually start at the very top and then keep drilling down. This one skips a few devs it skips a lot of divs and it actually starts at this post ID. But an absolute X path would start all the way here and then keep coming down until it gets all the way down to that element right there. So absolute ex-pat is obviously the easiest way to identify our element.
The problem is that it’s very long and that any change in the structure will break the locator. So for example, if you look at these two buttons you highlight the button and then take the control a Control-C to copy it over into my notepad over here for you guys and then. So that’s this button right button number one. Let me put button number two now check out these two buttons compare to each other. You guys see how they’re almost exactly the same. The only difference is that this is form too. And this is
But an absolute X path would start all the way here and then keep coming down until it gets all the way down to that element right there. So absolute ex-pat is obviously the easiest way to identify our element. The problem is that it’s very long and that any change in the structure will break the locator. So for example, if you look at these two buttons you highlight the button and then take the control a Control-C to copy it over into my notepad over here for you guys and then. So that’s this button right button number one. Let me put button number two now check out these two buttons compare to each other. You guys see how they’re almost exactly the same. The only difference is that this is form too. And this is form one where their location is different in the Web site because one is above another.
But what if I was to move this button over here on the side or move this X path to button on top or move it way on top or even get rid of this one. If that were to happen this would no longer be true because right if you imagine this is the bond that we want but now this bangup moved down here this would be its new address. You can think of this is like the home address. Right. If we want to go to this house the family in that house has moved to a different place. When you come here you’re not going to find the family that you want because you have the exact address. Instead what you need is a relative way to figure out where the family lives and then go to that location. Right. And that is something a good analogy there is if you had the family’s phone number that you wanted to visit and you say hey what’s your address.
And then they will tell you whether it’s this one or this one. It wouldn’t matter. But that’s where relative ex-pats command and help us make our jobs much easier rather than using absolutes and absolutes. Like I said are very easy but they are bad and dangerous. And when elements get shuffled around which they always do unless you’re working on a really bad application that never changes. You should use relative X paths. OK so don’t use absolutes. They’re just good to know. But we’re going to learn how to use relative paths extremely well.