Input Fields | Bondar Academy
Course: Mastering testRigor
Module: Interation with Web Elements
Instructor: Artem Bondar
Lesson Summary
In this lesson, we will explore how to automate input fields , interact with them in Test Trigger , and perform validation of the values within these fields. Interacting with Input Fields There are two primary methods to input values into fields: Option 1: Use the Enter command followed by the value to type. For example: Enter [email protected] into email below using the grid Option 2: Click inside the input field and then type the value. For example: Click input password below using the grid Note: The type command simulates keystrokes and requires the input field to be activated first. Validation of Input Fields To validate input fields, use the check that command: For a partial match , use contains . For an exact match , use equals . For regular expressions , use match projects to assert specific patterns. Regular Expressions A regular expression allows you to match specific patterns in strings. For example, to validate email formats: ^[a-zA-Z]+@test\.com$ This checks for any name followed by @test.com . In summary, to interact with input fields, use either Enter or type commands. For validation, you can use check that with contains , equals , or regular expressions to ensure the correct values are entered. Thank you for watching, and see you in the next lesson!
Video Transcript
In this lesson, we will talk about how to automate input fields, how to interact with the input fields in Test Trigger, and also how to make validation of the values inside of the input fields. So let's get into it. So here is our Form Layouts page. And in this lesson, we will type some email and password values inside of using the grid form and make a validation. So let's go to Framework and I create the new test. So first, I will navigate to Form Layouts page, click Forms, Layouts. And now let's type the email inside of the email input field. So what I need to do. So option number one, how you can type the values into the input field is to use the command Enter. Then I need to use a value that I want to type. For example, artem at test.com, something like this. Then I provide the action target, which is into email and the target location. Below using the grid is the name of our form. So let's double check using the grid and email. And I want to type it into the email and I can put, for example, input if I want. And let's run this test to see how it works. All right, test pass successfully. Let's check the screenshot and here we go. The email was entered into the email input field. So this is the option number one. What's the option number two? Option number two is first is to click inside of the input field and then type the value that you're looking for. So I type click into email below using the grid. And this time let's type into the password input field. Password input field. And after you perform the click, then you can use command type. And type what you want to type over here. For example, I type hello. And let's run this test as well. Okay, what I did wrong? The command is not recognized probably because I used this into. So let me remove this. Just click input password below using the grid. Update and retest. Okay, and it's running. All right, test pass successfully. Let's check it out. So we can see that there was first click performed into the password field. And then we type the value inside of the password field, which is hello. So what's the difference? The difference between enter is that you just entering or filling out the input field value. That's it. When you use click and type combination of commands, type simulates the keystroke on the keyboard, like you would normally type it from the keyboard. And also what you need to know that type command can be used only if you activated or clicked into the input field before using the click command. If you will not do this, type will not work. And also if you use enter command, you don't need to use type. So what is also other useful case for the type command? Type command can also perform other keyboard or keystrokes operation on the webpage. So if you go to test trigger documentation, by the way, documentation is available right here. Resources, documentation. We navigate to documentation, basic commands. And in this table, this is the command that we are using, type command. And this is the arguments that can be used. Enter, tab, escape, delete, and so on. So you can simulate different types of keystrokes on the keyword using the type command. And if in our script, we go back and for example, we type, type, tab, it will simulate the pressing of the tab key on the keyword. And in our example, we should navigate. So I put tab, we should navigate to the sign in button. So let me show you how does it work. So let's go back to the script. All right, test is completed. Let's check the screenshots. So this is the screenshot before, and this is the screenshot after. We can see that sign in button is in focus. So the tab selection worked successfully. All right, so let's move on. Let's go back to our input fields. And now let's make some validations. And I type validations just for my notes. And by the way, in Test Trigger, you can use a syntax of to forward slash to add any notes or comments into your code. It will not be executed. So it's just useful to have your own notes sometimes for the future references. So in order to perform validation of the input field, we need to do a command or keyword check. And what we are checking, check that, then action target, input email, then location below using the grid. And for the assertion, for example, for the partial match of the string, we can use the keyword contains. Contains, and let's say it contains Artem. For example, check that input field below using the grid. If we want to use more strict assertion or exact assertion, you can use a command equals to, and then we need to provide the exact value that we want to assert, the entire assertion. Update and retest. All right, test pass successfully. Let's check it out. So Test Trigger highlighted the assertion input field that was validated. So both of the assertion pass successfully. So one more time, if we use the contains, it will make a partial match for the string inside of the input field. If you use equals to, or you can type something is equal to, it will make assertion for the entire exact value. For the entire exact string. And the third option that you can use is using regular expressions. So what is a regular expression? Regular expression is a special type of the syntax, which you can use to match a specific pattern inside of your string. So you can use maybe ChatGPT to generate those, or you can use Regex Builder, something like that, regex101.com, to match the string that you're trying to match. Let's say that for the purpose of our test, we want to validate that it should be any name, and then the end of the email should be exactly attest.com. And any name in front of attest.com is completely fine for us. So we can build a regular expressions based on this pattern. So here I'm going back over here, and the quick reference you can use right here, how to build those expressions. For example, if you want to use any characters from A to Z and capital A to Z, or lowercase, and so on. So our string should start with the caret sign and end with the dollar sign. So we put the caret and the dollar sign. Then in the middle, we need to put the name. So it will be any lowercase characters. So I would use this A to Z. A to Z. And by the way, here in this field, I need to put the string that I want to match to see if the match happens or not. So you see right now, match is not happening because string is not completed. Then I need to add plus at test.com. And for the dot, I need to put the escape character. And that's it. Our string is ready. You can see that this is highlighted. And also here in the match information, we can see one match and it match the string. So this regular expression is ready. I just copy it. Going back in here in the assertion, I type match projects and provide the string for the assertion. So let's run this test. And this test passed successfully as well. The assertion with the regular expression worked as well. So let's quickly summarize what we did in this lesson. So to interact with the input fields, you have two options. Either user command enter and type the text value that you want to type into this text, or you can use a type command that will simulate the keyboard keystrokes. But you need to use a click inside of this input field to activate this input field before performing the typing. Also typing can be used to simulate other keystrokes on the keyboard using tab, arrow up, arrow down, and so on. And to validate the values inside of the input field, you have three options. Option number one is using the check that, then provide the location of this input field. You can use a partial assertion of the text using contains command. You can use exact assertion of the text using is equal to, and also you can use a regular expression using match projects and provide the value of regular expression to match the pattern of the string that you want to assert. All right, that's it guys, and see you in the next lesson.