As per the requirements, "XYZ" field is mandatory field, but this field is optional in the form which I am testing.
"XYZ" is a text field. So when I automate the form, whether that field is empty or filled it passes. In reality, this test should fail.
I am using TestNG and selenium.
Thanks!!!
Leave the text field empty, click on Submit to submit the form.
Check for any validations "Please enter text here." or "1 missed field".
if the the validation alert is not seen, the test script will fail and that is how you will catch it.
Think of selenium as a way to replicate a real user click through on a website. So when manually clicking through, you clicked to submit the form and went to the next page when you actually expected a validation alert.
Related
I want to check that if some fields in the form view has been checked or not. If they have been checked then show a confirmation message and if not then a error message saying that those fields must be checked. For this functionality I have created a button which calls a specific function in the model. The button has also attribute confirm which enables the confirmation pop up box. But all the time it first opens the confirmation message and then the checking for the fields. I want to have the other way around how to achieve this. Please help.
I am working on a Word template that has 5 text boxes on a user form (frmMain).
I have a validation routine for each text box, that checks if the correct format is used (i.e. date format in one text box, only allowing the use of numeric values in another, preventing all text boxes left empty and so on). One of my text boxes is called txtNumber.
As of now, one of the validation sub routine fires on txtNumber_Exit.
I also have a command button (cmdHelp) on the same user form that, when clicked, fires the sub routine that shows another user form (frmHelp) that contains a help text on how to use this template.
My problem is that when I click this command button (cmdHelp), the validation routine for the text box "txtNumber" fires. Hence I am stuck with a message (written by me) in a msgbox that says "Number can not be blank", and the frmHelp is not showing.
After this, none of my text boxes have the focus, but my cmdHelp button does.
So if I click the cmdHelp button now, the frmHelp is correctly showing.
But this is messing up the workflow, making the visual experience a bit fuzzy for the user, given the fact that the user gets unnecessary info on invalid input in the txtNumber text box, and that the user needs to click twice on the cmdHelp button.
How can I avoid this?
I have an exit button in my application which I want to write a story for. It behaves this way:
If I have content filled in the form I am editing and I click on the exit button, it will pop up with a confirmation message letting me know there are unsaved content and if I am sure I want to exit from the page.
If I do not have any content filled in the form I am editing and I click on the exit button, the confirmation message will not show up and I am instantly exited from the form.
What I have so far is something like this:
Given as a User on New Profile page
And I fill in the customer name = "Bob"
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
My question is the part on And when I fill in the customer name = "Bob" only covers one of the fields. How do I write the story in a succinct way that if any of the fields are filled or chosen (drop downs), the confirmation dialog will show up ? Secondly, is my story correct ?
You can use a scenario outline in conjunction with parameterizing the step that fills in a field with a dummy value.
Scenario Outline: The user is taken to the landing page after exiting new user profile
Given I am registering as a new user
And I have filled in the "<Profile Field>" field
And I have chosen to exit the current page
When I confirm I want to abandon my unsaved changes
Then I should be redirected to the landing page
Examples:
| Profile Field |
| Name |
| Phone Number |
| ... |
You didn't post the scenario title, which is just as important as the wording for each step, so I made on up. The important thing is to focus on the behavior:
Scenario Outline: The user is taken to the landing page after exiting new user profile
The step Given I am registering as a new user should navigate to the new user profile page.
The step Given I have filled in the "<Profile Field>" field should accept an argument where you name the field you want filled in. The definition for this step should fill in the field with dummy information, or blindly chose an option in a dropdown.
The step Given I have chosen to exit the current page should click the exit button. Notice there is no mention of "clicking" on anything. You should avoid language in your steps the sound like instructions on how to use the user interface, and instead focus on the behavior of the application using business terms.
Same thing for When I confirm I want to abandon my unsaved changes. It does not mention clicking on anything. It just focuses on the behavior (choosing to abandon your changes). The step definition should know how to click the "OK" button in the confirmation dialog. The fact a confirmation dialog even exists should only be known by the step definition.
Finally, Then I should be redirected to the landing page makes your assertion about where the user ends up. I like to include the word "should" in my Then steps. If find it easier to pinpoint the test failure when a Then step fails. The condition that comes after the "should" in my step is usually the thing that fails.
you can use datatable in that particular step as below
Given as a User on New Profile page
And I fill in the customer details
|name|address1|adress2|pincode| //can be accessed with DataTable datatype in SD*
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
*SD-Stepdefinitions
I have registration form for which I am trying to create a script.If we don't enter any value in any of the fields and click submit, it is showing a dynamic error message that "Please fill out this field!"
There is no div tag for this text. Moreover, if we click anywhere on the screen, it is disappearing. Can anyone tell, how to read this text?
Thank you.
When the field is marked as required, the Browser shows the message when the form is submitted. There is no way available for you to access it.
You can handle it within your test code by checking that all required fields are entered before submit is called.
I have a struts application that has a form to edit user details. I am using struts validator to validate the user input.
I have a checkbox that, when clicked, makes 'Password' and 'Confirm Password' input boxes appear.
If the checkbox box is UNchecked, I do not want the app to validate the invisible input boxes. If I check the checkbox, I then want the validator to kick it.
I have put an c:if around the to only display if the checkbox is checked.
My problem is that the Password/Confirm password validation kicks in, but is invisible.
My question is, is there a way to only validate an input box based on a checkbox value?
Not sure, but i believe you can use validWhen" validation, this validation is for such use-cases for more details refer to the official doc
validator