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

Take This Entire Course for Free

What will you learn in this lecture?

In this video, we will go through the how to use className to identify an element of the Elements Identification course.

Selenium Tutorial – How to Use className to Identify an Element


So let’s talk about a class name. Class name is obviously the name of the attribute and it’s OK not as good as an ID and use it only if you must. Sometimes it may be unique. Sometimes it’s not. That’s for you to figure out whether it gives you a unique identifier. So for example if we come back to our automation testing practice page and we hover over this button that says click this button using class. This one has a class so you guys can see here that it’s attribute is named class and then its value is Borton class example. So if we take this value and we come over to our selenium ID and rather than doing this I’m going to do it for you guys from scratch will do the standard driver. First let me say that are equal to a variable of our equals.

Actually we don’t even need to because I created a private element up here so we have to do is Element equals we don’t have to declare it and driver dot find element by how class name and supply the value and then scroll over here put the semi-colon and come back here. Uncommon that so that it navigates back and let me comment on this so that it doesn’t do that control. Casey is quickly to comment. You can also just tie light go to it advanced and comment selection. Ok that’s in Visual Studio 2015 I think the other ones it’s a little bit different because I think in 2013 it was like Control see you or something I forget. It’s annoying how they always change.

But that’s what it is for me now. But you guys can do it through the advance that it. Anyway so now we have that set. So if I run this and actually do a debug when the debug pulls up our unit test Rahner then it pulls up the browser. So now we’re here if we step over this we’re going to have our elements stored. You guys can see we can look at it easily right here. That’s why I like that two line technique. You can see it’s size tag name import taxes and have any text whatever else. And now if we hear it oops and of course I forgot to do the click. So one nice thing about Visual Studio is it allows you sometimes to edit on the fly in debugging mode. So if I do element click put that in there so now it’s going to click and you see right now the arrow is pointing to this line.

I can actually move it up one take that. So now it’s going to do this line instead. So I’m going to step over and now click and check it out button success because it was one success means that clicked on the right button. And now we can just go ahead and do an EF 5 to run through everything. And the reason I did that five is because I added a test clean up method here at the end of the test so that it does a drive or door close and the driver that quit and let me pin this over here so that it stops bothering me. Excellent. And so the driver got close and the driver got quiet. You can see this one closes the current window quitting the browser and then the quick quits this driver closing every associated window. Excellent. So I’m going to save that.

Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones, community, and the world at large. Today, he serves as the CEO and Test Automation Instructor at UltimateQA.com and contributes informative articles to leading test automaton websites like SimpleProgrammer.com and TechBeacon.com

Pin It on Pinterest

Share This