Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » Optional Step--a new way of Coding in QTP

Consider a situation where a statement is not that much important to execute a test.But for QTP if that statement is not get executed might give an error and stop execution.


I can well remember one line of a QTP workshop where the trainer was explaining one scenarion..
he needed to execute 1000 time a testcase.He divided the the execution in 10 different machine which will execute 100 times each.He saw everything started fine and then he left for the day.


When came back next day morning and collecting the results he saw (to his bad luck) 8 machines got an error message on file download extra worning which was recorded initially. During execution it never appear.


Consider the trainer's problem.He needed to start the execution from where they got stopped.
We ware discussing this problem ,when my friend(Dadu) suggested one solution...Well Dadu is a great QTPian.He created a Hydrid framework.As per him ,we can add few extralines to mitigate this risk.


The construction can be...


if Browser("XYZ").Page("ABC").WebButton("PQR").exists(3) then
Browser("XYZ").Page("ABC").WebButton("PQR").click
end if


The construction is very straight forward...if that button exist in the application then it will click else it will continue to execute.


Wooooooooooooooo...what a solution ...we all were celebrating this solution by implementing this code. Even i posted this code to my blog(See my previous blog entries)


But you know what!!!!!!!!!!!!!!....those celebration stopped quickly when we faced different kind of problem.
Well let me explain..There might be scenarios where
1. The developper has changed the object name in the test but the OR (Object Repository) is having the same old name)
2. The Developper has added/readded one object but the OR is not updated with this updated object.

Then this simple non value add line can stop your execution.Well Dadu could not answare this question.
Yes ...we were looking for this solution...might be you all at this stage are looking for a solution ...may be blaming HP for not implementing such scenarios like us....




YOOOOOOOOOOOOOOOOOOOOOOOOOOOOO



we got the answare....
It is Optional Step...


If QuickTest cannot find an object designated as optional while running a test, it bypasses the step, and continues the run. By default, QuickTest automatically marks steps that open certain dialog boxes as optional. You can manually designate additional steps as optional.

It is applicable for the below written dialog boxes..
  1. Dialog Box Titlebar
  2. Any other Dialog Boxes
  3. AutoComplete
  4. File Download
  5. Internet Explorer
  6. Netscape
  7. Enter Network Password
  8. Error
  9. Security Alert
  10. Security Information
  11. Security Warning
  12. Username and Password Required


Setting Optional Steps


When recording a test, the application you are testing may prompt you to enter a user name and password in a login window. When you run the test, however, the application does not prompt you to enter your user name and password, because it has retained the information that was previously entered. In this case, the steps that were recorded for entering the login information are not required and should, therefore, be marked optional.



When running a test, if a step in an optional dialog box does not open, QuickTest bypasses this step and continues to run the test. When the run session ends, a message is displayed for the step that failed to open the dialog box, but the step does not cause the test to fail.



To set an optional step in the Keyword View, right-click a step and choose Optional Step. The Optional Step icon is added next to the selected step.



Note: Note: You can also add an optional step in the Expert View by adding OptionalStep to the beginning of the VBScript statement. For example:


The code looks like:

OptionalStep.Browser("Browser").Dialog("AutoComplete").WinButton("Yes").Click

The part of it is ....Any other step can also converted to OptionalStep which can be avoided during execution.

So, Guys make any doubtfull steps to Optional Step which will pretend as On Error Resume next.
More about Optional Steps:
An optional step is a step that is not necessarily required to successfully complete a run session. During a run session, if a step in an optional dialog box does not open, QuickTest bypasses this step and continues
to run the test. When the run session ends, a message is displayed for the step that failed to open the dialog box, but the step does not cause the run to fail.


Enjoy.

«
Next
Newer Post
»
Previous
Older Post

1 comments: