TestProject Forum

Working with HTML tables

Hello all!

I’m trying to interact with an HTML table. I would like to check a particular checkbox depending on the value received by the test parameter:


For example, the test case receives an input parameter with the Description, for instance, ‘Grade’ in order to activate it, checking the respective checkbox.
What can be the better way to achieve this goal using TestProject?

Thanks in advance.
Best regards,
Sandro Pinto

Hello @sandro.pinto
You can create an xpath that captures the correct checkbox according to the Text, Grade for the example.

Say you have the following DOM structure:

  <input type='checkbox'/>

You can build the XPATH like so:

This will capture the checkbox that corresponds with the text.

Of course this changes according to the DOM of the app but the concept stays the same

Thank you @ran.tzur for your reply :wink:

Your suggestion makes very sense to me. However I don’t have enough knowledge about XPATH to be able to follow it.
This is the DOM of my table:


How can I create an HTML element for the checkbox which is in the ‘Grade’ table row?

I started using the Action ‘Search text’ provided by the below Addon that allowed me to achieve my goal. Using that action and storing the row index in a parameter that can then be used in the HTML element XPATH locator as: //tr[{p_OUType_row}+1]//input[1]

That’s a great solution and usage of the HTML table addon