Webdriver Html Table (C#)

Let’s talk about one of few useful features from Coded UI Studio and how to use it in webdriver. Aka how to deal with Html Table.

What is Coded UI Studio?

If you have heard, Coded UI Test is slowly coming to its end.
Visual Studio 2019 is the last VS that will have Coded UI Test.

In my working career, I spent over two years working with CUT. I think it has a lot of problems, for example only IE support but it also has a few nice advantages. for example, it could both record browsers (only ie) and windows desktop. It also an interesting way of dealing with HTML elements.

Where selenium sees all element as the same and gives you same action. it doesn’t care if something is a label, input or checkbox. You will always have the same options, like send keys, read text or checking if the checkbox is „checked”. – they are ale IWebElement and that why they have the same options.

The Html Table

Coded UI works different, it has different classes for TextBox, inputs and labels. IT has its problem cause while finding elements you have to decide what type of element it is. For example, if you try to provide a locator for the textbox to label element, it won’t find it.
But thanks to it you won’t see an option to send a text to the label.
This approach gives also the option to do some more advanced options.
My favourite and so far the most useful is a mechanism to deal with Html Table.
So much that in my past I have done my own implementation of that feature in most internal selenium frameworks I have worked with.

Ok, what so unusual about it?

Its a fast and simple way of dealing with Tables.
you don’t have to take locators for single cell you need to use. you can just point it to the table loot and the rest is done for you.
Do you want headers? One command and done.
Do you want to get specific cell – give it location and you have it.
You want to know how many cell or rows is there? Again one.

Ok, nice, but what is the point of this post?

As I said I have implemented its feature in internal frameworks based on selenium at least 3 times so far. I am a little tired of doing it over and over again. So I’ve decided to create a NuGet package for it. Here it is.

Right now it is in early stages alpha but it works for basic scenarios.
I am looking from your help. If any of you have some feature suggestion or find tables where it’s not working let me know. On Github you can report issues and sugestions.

Dodaj komentarz