What will you learn in this lecture?

In the previous video, we learned how to use an ID to identify elements of this Selenium webdriver elements identification course. In this video, we’ll still learn how to use an ID to identify elements, this time with Selenium Webdriver.

Using an ID to Identify Elements w/ Selenium Webdriver

So my point about IDs is that they are the best element to use for identifying your object. Now let’s go ahead and actually transition that to C# and Selenium webdriver.

So if you guys go to my code to nadvolod lightpom framework tutorial and then what you can do is if you have a Github account, you can obviously clone, if you don’t you can just download the zip file.

Download the zip file. Extract the code and you’ll be able to follow along in this tutorial. So that’s what I have here in the solution explorer under element identification test in QTP tests project.

You guys can see here I have a bunch of element identifiers but we’re going to go through for Selenium webdriver because that’s our ultimate goal right is- to master this thing.

So if we want to find an element using an ID, we need to do this. So I’m going to do Ctrl K U you to uncomment and we can run this test. Now, here on top of the test, I set up a static driver that’s going to open up Chrome for us an element called element and then a locator which are used further below.

So the first step that we do in our test is we go to a URL which is our web page and then we find the element using that ID and then we click on it. And then the other thing that we need to do is go back because once we click on the element, we want to go back to that element.

So, we’ll actually debug through this so that you guys can see what’s happening. So I’m going to go ahead, click here and then do debug and then it’s going to run up to this point so I get my unit test runner here let me pin it here comes Chrome.

I’m going to put it on the side and then my Visual Studio on the left side.

Now this page opened. This line right here uses the driver that created up here on top. It’s a static one so we don’t need to recreate it again.

It has a find element method using a locator called ID and which button do we want to click on well let’s take a look at our Firefox.

I’m actually clicking on this button here so if I select it. Its ID is example and you guys can actually see here in the HTML. Remember what we learned here is the property and here’s its value and that’s exactly what we want we’re using this ID and its values ID example.

And so I just put that in here and then if we’re successful, it should click on that button.

So I’m going to go ahead and step over this now.

We have this element stored in a variable and you guys can see all the information about it in here something like even a tax no text and then we can step over this and it’s going to perform a click action.

And look at that, you guys see that it clicked on it on button success and it was successful it’s clicking and now this action here is going to take us back step over and that’s going to use the browser to take us back.

Fantastic. I’m going to stop that.

Next Tutorial

In the next tutorial, we will learn about the webdriver commands.

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

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

Shares
Share This