Exception Handling in Coded Ui Testing is one of the most powerful of the innumerable tools available within the VSTS Functional Automation framework. VSTS testing involves the record and play approach with the assertion points playing a major role in validating the various scenarios as and when they arise.
Going by the simplest assertions of all is the string Assert.contains assertion point which we bring to an immense use . The very relevance of this very assertion can be understood from the genuine scenario of logging into the application as discussed in some of my previous topics with Coded Ui Testing. Logging into the gmail application, however aany tester can validate and verify the authentication by checking whether the signed in user name is displayed as was used during the logging in process.
For example suppose Viplav15 has logged into the gmail website, we generally put an assertion point validating the display of viplav15 in the top right hand side of the gmail application. In all functionl automation testing Validation is a must , we use different naming conventions in the various tools language such as checkpoint in QTP and an assertion point in VSTS.
We will use string assert.contains verification point / assertion point to validate that the logged in user is as per the expectation.
But now just do one thing.
Log out from the application and then login with a new userid.
DO you get surprised as to why I ask you to do this?
I know you would. But I would just say you would figure out one of the most indispensable of the many features of VSTS CodedUi testing getting exposed with perfect ease though I struggled to get it under my knowledge belt in short time period.
Now we have a new user logged into the application : gmail.com
The new user is not viplav15 may be its some xyz..
And what do you think you need to validate this time ?
And you have to validate that the new user is not “viplav15”.
I do not ask you to validate that the user logged in is xyz or whosoever it be may be your girlfriend or boy..
What my expectation is you need to validate that the upper right panel does not contain viplav15 anymore.
Do you think VSTS CodedUi Testing has anything of the sort of String assert.doesnotcontain ?
Sorry to say but it does not contain any such assertion point . So how is it we can get this scenario covered ?
In fact if you are not a quality tester , you might just not understand the reason why I have been stressing so much on the not presence of some particular controls.
This is the place wherein we can bring some of the best of coding practices in place and may be remove some of the shortcomings that we might have been concluding to be present in the VSTS tool itself.
Do you think this has any solution ?
No!!!
Even I used to think the same but today have a very genuine solution to it and in fact a lot more of such related issues which I used to think to be a shortcoming within the tool.
Uitestcontrolnotfoundexception.
Playback.error exception
Assertionfailed exception.
Put the complete assertion function call within the try block.
Try {
Assertion_Fun1()
This.contextwriteline(Test case passed)
}
Catch(exception playback.Assertionfailed )
{
This.contextwriteline(Test case failed)
}
The above code will be useful for the string assert.contains validation.
For the negative scenario validation :
Try {
Assertion_Fun1()
This.contextwriteline(Test case failed)
}
Catch(exception playback.Assertionfailed )
{
This.contextwriteline(Test case passed)
}
We will take this in detail with an example in the next content. Till then keep exploring the VSTS Functional automation tool offering bets automation at lowest cost.
إرسال تعليق