Web Tables Scenarios and Assertions | Bondar Academy
Course: Mastering testRigor
Module: Interation with Web Elements
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore realistic scenarios for validating functionality within a web table, specifically focusing on updating values and making assertions. Key Concepts Web Table Interaction: We will validate the functionality of updating user details by ID. Test Scenario: Update first and last name for a user by clicking a pencil icon. Steps to Update User Information Navigate to the Smart Table Page: Start by accessing the web table. Locate the Edit Button: Use class and edit to find the pencil icon for the specific row (e.g., ID 3). Update Values: After clicking the pencil, locate the first and last name fields using the check mark as a unique identifier. Save Changes: Click the check mark to save the updated information. Assertions After updating, we validate that the changes were successful by checking: First name for ID 3 should equal John . Last name for ID 3 should equal Smith . Adding a New User We also covered how to add a new user: Click the plus icon to initiate adding a new user. Enter the first and last name in the table header. Save the new user and validate that the user appears in the first row of the table. In summary, working with web tables involves careful interaction with elements and making precise assertions. Practice is key to mastering these tasks.
Video Transcript
In the previous lesson, I showed you some of the typical examples that you can use when you work with a web table. And in this lesson, we will write some more realistic scenarios for the web table and we'll make a few assertions. So I will show you how to make validations inside of the web table. So let's get into it. And here is our web table. And imagine the scenario that we want to validate the functionality of updating the values in the table by ID. For example, we want to update the first and last name for this user. And in order to do that, we need to click on this little pencil, write first and last name into this table, click Save, and then perform validation that this update happened. So let's write a quick scenario to test this functionality. So go to our framework and I'm writing a new test. And for the first step, we need to navigate to the smart table page. So let me copy these steps. Okay, and the first scenario will be update first and last name by ID. All right, so what would be the first step? The first step, we need to find out the locator for the little pencil to click for the particular row. So let's make a right click inspect. And what we see, we can use this class and be edit. And just for the simplicity, we can use only edit and we will say click edit. And then we need to provide the row where it should be clicked. So we want to select the row, for example, for ID number three. And for the user with ID number three, we want to update first and last name. So first step is to click on this pencil by ID number three. So let's do this. So the prompt would start with click on button, edit. Then standard expression in the context of table with exactly ID equals to three below actions. Actions is our column where we would look for this pencil below the actions and ID number three. All right, the next step. After we click on that, we can update the values for the first and last name inside of the table. And the way how we can locate this role is by this check mark or by this icon. Because this check mark becomes unique for this entire page. It exists only here. So we can locate first and last name columns in the row that containing this check mark. And let's find what is the class for it. And it is and be check mark. So we can use check mark as a locator. So and we type enter. Let's say john into table at row containing check mark and column first name. And the same thing will be for the last name. So we want to type enter. For example, Smith into table at row containing check mark and column last name. And the last step, we need to save it by clicking on this check mark. So we need just click and check mark. And I believe that's it. So let's run this test and let's see if it is working. Okay, we have some error. No pointer exception with message. No can recognize any action. Click on button edit. Let's see. Click on button edit in the context of table with ID exactly three and here below actions. And we need to provide here at column actions instead of below actions. All right, let's try to run more time and it is working right now. Let's see the execution. All right, test pass successfully. Let's check the screenshots. So we find out the correct pencil for the ID number three. Then we updated the values for John Smith and we click on the check mark and the values were updated successfully. Perfect. So it worked as expected. And now let's make a couple of assertions for those values that they are actually updated in the table. Check that. And we need to find the row with ID three and say that the first name should be equal to Larry and last name should equal to Bert. So we're still looking by ID three. So how would we do that? So check that table with ID exactly two, three and column first name is equal to John. And using the same prompt, we will use check the table with exactly three with last name should be equal to Smith. And let's run this. All right, test pass successfully. Let's check the screenshot. You can see the highlighted area. Both cells were highlighted and assertion passed as expected. So let's add one more scenario. For example, we want to test that we can add a new values into the table. So if I click this plus icon, I can create a new user, for example, Artem Bondar. And then I click on the check mark and this value is created in the first row of the table. And we want to validate that when we create a new user, it is added as a first user in the row. So let's do this again. We need to find out how we're going to click on this plus icon. Let's see if it has anything. Yes, it has a plus. So we will click on that and then we need to enter new values in the first and last name. And I will show you a little interesting trick, an interesting new prompt over here. Because table has a table header and table body and this row will belong to table header. So your prompt should be a little bit different to interact with a table header. So let's get into it. And the second test will be add a new user to the table. So first step is click plus. Then we need to find the row that has this check mark. So it's very easy. We can use the previous example. So where is that? Enter John into table containing first name. But instead of into table, we provide into table header at row containing check mark. Because we are interacting with a table header. And I type here Artem. And copy this one more time. Enter ponder into table header at row containing check mark and last name. Then we need to click on the check mark to save those changes similar to the previous test. And the last two steps is to make assertion that the values added to the table in the first row of the table. How would we do that? This assertion would be pretty simple. So check that table at the first row and column. First name is equal to Artem. And the same thing. I'll copy this. Check that table at first row and column. Last name is equal to ponder. And here is a little misspell. Equal. Equal. All right, let's run this. Nope, something is wrong. I couldn't identify action for the element for validation table at the first row. So let's see. Check that table at the first row and column. First name is equal to Artem. Okay, let's run this. And something didn't work. So let's see. We didn't type the values for some reason. So it made the assertion. But we click the check mark without typing the values. Something didn't work. Let's double check what we have here. So into table header at row containing check mark. So let's type this. Into table at header row. At header row. How about that? So into table at header row containing check mark. So update and retest. And now it looks like it works successfully. So we click on the plus. Edit Artem Bonder. We saved it. And we validated that first and last name in the first row of the table. So that worked successfully. All right, so let's quickly summarize what we did in this lesson. So as you can see, working with the tables sometimes can be pretty tricky and pretty challenging. Because working with those prompts and tailoring those prompts requires some practicing. So we talked about how to make the assertions of the values inside of the table. And also how to interact with the table header in case you need that. Also, you can pick the rows of the table inside of your table by the index first row, second row, and so on. And perform validations that way. All right, that's it, guys. And see you in the next lesson.