What will you learn in this lecture?
In the previous video, we learned how to get an HTML table in a variable of this Selenium WebDriver elements identification course. In this video, we’ll have to learn how to use C# to find a cell value.
How to Use C# to Find a Cell Value
All right! So let’s go ahead and step over this line to see what happens to our collection of rows. I’m going to step over that as well, scroll up a little bit, hover over this collection of rows. And you guys can see the counters four which is absolutely right, correct because we have 1, 2, 3, 4 rows.
Here we can expand them and we can drill down into each one. You can see the very first one has the title, work and salary. The next one has a software development engineer in test automation and $150,000 and so on and so forth for each of the rows.
How cool is that! And all I did was just pass in the XPath that we talked about into our find elements method and that returning a collection of iWeb elements into this variable. Cool, right? So let me go ahead and just run this through.
So it closes my browsers and cleans up. And now I have a fun challenge for you guys which is usually what the problem that people face most of the time. And that is, what is the salary of an SDET. Meaning, software development engineer. And test what is their salary.
If I was to ask you that and then ask you to write code in order to get that salary, how would you do it?
So that it’s dynamic, right? So that if tomorrow the salary changes to $200,000 you’ll still get that salary. Or maybe instead of a salary of an SDET, you want the salary of an automation testing architect or maybe you want to know the work that an automation testing architect does.
It needs to be dynamic like that. Not just finding the value here, but you need to find this value based on this column and this row. Okay!
So that is the problem that we’re going to solve. And it will basically help us to combine all of the skills that we have learned so far into one final nice project.
So let’s take a look at this code here. The very first thing that I did was set up a few variables. Here, I set up a column index, a column counter, a constant called “desired column header”, right?
So this is the column that we want. We want the salary. And then what is the desired value? Which is the software development engineer in test. Okay! We want the salary of the software development engineer in test. And now we obviously need a loop, right?
We can get a table, get all of the rows. And then based on that, we can figure out where this salary lives and where this lives as well.
So let me uncomment the sole loop.
[Tweet “Learn everything about elements identification with Selenium Webdriver.”]
In the next tutorial, we will cover how to use C# to find all cells in a row.
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
[Tweet “Learn how to correctly identify elements using #Selenium #Webdriver.”]How