Micro Focus QTP (UFT) Forums
Can anyone give me some tips to automate tests? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Can anyone give me some tips to automate tests? (/Thread-Can-anyone-give-me-some-tips-to-automate-tests)



Can anyone give me some tips to automate tests? - sepgs2004 - 02-25-2009

We have these requirements in our workplace... I just managed to learn to create tests individually and run them individually using QTP IDE (Run button).

Requirement 1:
I have 5 tests. I would like to have a script to run all of them in sequence. I am new to this testing domain.
Requirement 2:
Sometimes I might have to run one test so many times, every time let the test open a new browser window (should leave the earlier test browser window open). So if I ran the test 10 times, at the end, I will have 10 browser windows open.

Please give me some tips or share some info on how you do this?

Thanks for your time.


RE: Can anyone give me some tips to automate tests? - papu - 02-26-2009

Soln to REQ1:
You can use 'Test Batch Runner' to run several tests in succession. (Start->All Programs->QTP->Tools->Test Batch Runner.

From 'File' menu select 'New',Then from Batch menu select 'Add'.Now 'Open Test' dialog will open and you can add your 5 test to it.Svae it as .mtb file. Now you can run it(F5 or Batch ->Run) Make sure that in QTP tools->option->run tab 'allow other mercury product to..." check box is checked.

Using Test Batch Runner, you can set up a list of tests and save the list as an .mtb file, so that you can easily run the same batch of tests again, at another time. You can also choose to include or exclude a test in your batch list from running during a batch run.

Soln Req 2:
For this in tools->option->web tab -> 'Advance' option->check the 'browser cleanup' check box under the 'run seting'
Also you can close all the browser programetically after finishing your test steps.
Code:
(use systemutil.CloseDescendentProcesses() /systemutil.CloseProcessByWndTitle("Internet Explorer")


Also let me know if this meets you requirements.


RE: Can anyone give me some tips to automate tests? - sepgs2004 - 02-26-2009

Thanks for the answer. I hit another issue.

Used the batch runner. As the first test updates/inserts values into the global data table to pass it between actions, I think the test becomes an unsaved one after it runs; then when test batch runner tries to go to the next test in the batch, it could not...saying "Unable to close unsaved test".
I checked test run settings.. etc. Is there any way, we can tell the test to save before closing after a run. Or is there any (script) programmatic way to do this.

For solution 2, we do not want to close the browser window after a test-run. In other words, simply open a new browser every time the test runs ignoring the existing browser windows.


RE: Can anyone give me some tips to automate tests? - sepgs2004 - 03-02-2009

I used the batch runner and I mentioned the following issue:
As the first test updates/inserts values into the global data table to pass it between actions, I think the test becomes an unsaved one after it runs; then when test batch runner tries to go to the next test in the batch, it could not...saying "Unable to close unsaved test".
I checked test run settings.. etc. Is there any way, we can tell the test to save before closing after a run. Or is there any (script) programmatic way to do this.

I guess I was wrong. Probably I clicked something while the batch runner was running the test and it made the test to "unsaved" status.
Actually Batch Runner works great.

Then I asked about the following requirement:
"Sometimes I might have to run one test so many times, every time let the test open a new browser window (should leave the earlier test browser window open). So if I ran the test 10 times, at the end, I will have 10 browser windows open."
Papu wrote a solution:
Soln Req 2:
For this in tools->option->web tab -> 'Advance' option->check the 'browser cleanup' check box under the 'run seting'
Also you can close all the browser programetically after finishing your test steps.(use systemutil.CloseDescendentProcesses() /systemutil.CloseProcessByWndTitle("Internet Explorer")


Actually, the above solution is to close the browser window each time a test session is over. I do not want to close the browser window, and still want the test to use a fresh another one every time it runs, leaving the open window as it is. Is this possible? Like the load testing.