I'm creating a simple webtest (Recorded Web performance test) that makes sure that a correct error message is displayed if i try to login with a username that does not exist.
However, there are two types of error messages that handle incorrect login info. One is for all the usernames that do not exist and therefore are not allowed, and the other is for usernames that start with the letter 'Q' (which is not allowed for开发者_如何学C a few reasons).
Now what i want to do is use the 'Find Text' validation rule and the test should pass if ONE of the 'Find Text' parameters is found, and in that case i want the second 'Find Text' rule to be ignored so it doesn't fail the test.
In other words the test should always pass if one of the 'Find Test' rules is found.
How can i achieve that? Is there some if,else statement that i can use for this?
Another way of doing it is by using databinding. If you have a data source defined for your web test, like a table called ForbiddenUsers like this:
Username Message
-------- -------
Quasimodo You are not allowed to use this system.
NonExistent Who are you?
Then, provided that you use the {{ForbiddenUsers.Username}} from the data source in the login part of the test, you only need to add one Find Text validation rule, with the property 'Find Text' = {{ForbiddenUsers.Message}}
This will map the proper Message for the desired type of Usernames.
Yes you are on the right track: VS 2010 has conditionals.
- In your test, right-click and choose Add Conditional.
- Choose the String Comparison rule, set Use Regular Expression to true, set Value to ^Q.*?$, and set Context Parameter Name to the context parameter containing the username value.
- This will match usernames beginning with Q.
- Add the login request to the conditional, and add the appropriate Find Text rule (that finds the Q-username error message) to the request.
There is no notion of else, unfortunately, so you'll have to make a copy the Conditional node, and in the copy, change the Comparison Operator to Not Equals, and then modify the copied Find Text rule to match the regular non-existing username error message.
The resulting test should look something like:
-If ( {{username}} equals "^Q.*?$" )
-http://login request here
-Validation Rules
-Find Text <--- match Q-username error message
-If ( {{username}} does not equals "^Q.*?$" )
-http://login request here
-Validation Rules
-Find Text <--- match non-existing username error message
精彩评论