Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
closing browser at end
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi

I currently have as my last step in qtp
Browser("aALIWeb").close


this will close the browser in qtp ... IF the test ends normally.

But, I have the setting that upon error, QTP should stop the run.
The run gets stopped in the middle of the test so the close is never
executed.

How can I have the browser be closed whether the test ends normally or by error? I need it closed so for the next test I can open a fresh copy and not have the state of the web page be wherever it left off before.
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Well, thats the caveat when you have the tool take over the control. Ideally, when you stop an execution it should be controlled via the code, but nevertheless, QTP has the option so why not use it. However, it ends up like you can either have the egg or the chicken Smile

Now since it is controlled by QTP and you cannot insert a code after the error occurs, the easiest would be to,
"Look for any open browsers and if they exist close them before a test execution Starts".

However, this would be a very primitive and not a best practice suggestion. The best way to do this is to handle errors in the code using the On Error Resume Next and then capturing those errors using Err.Number and logging them. This way you will have un-interrupted execution as well you know specifically the ones which failed.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Thanks Basanth, I thought of closing open windows at the beginning of the test, but wouldn't that close itself too? I want the browser that gets open when the test starts to stay open.
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
No it wouldnt. Here is what i meant,

First Line of code, before you do any action - Close all Open Browsers.
Second Line - Open your test browser.
This way, you will not close the current browser you have and it will ensure that the system is set to base state where everything starts clean.


No, It wouldnt. Here is what i meant,

1. Before you do anything, Close All the open browsers. This should be the first line of code.
2. Your subsequent lines should contain the test browser you intend to open.

Yes, This will after each test execution, will close the browser in action and open the new test browser.

In case if you know what is the possible error, then you could probably try the recovery scenario. But, It isint my good friend as it will slow down the test execution.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SAP GUI gets hanged while closing the Windows Pop Up kathirvelnagaraj 0 5,530 10-23-2015, 06:47 PM
Last Post: kathirvelnagaraj
  Expected End statement error Lavanya N 2 5,160 07-27-2015, 01:52 PM
Last Post: Lavanya N
  recovery scenario for closing a message box itself ashima 0 2,238 12-26-2013, 11:10 AM
Last Post: ashima
  error object disabled on line 9 where it says " Browser("Browser").CloseAllTabs" kp_usa 1 3,344 12-20-2012, 12:20 AM
Last Post: adityapant27
  closing the browser diya 3 3,608 11-27-2012, 10:14 PM
Last Post: diya

Forum Jump:


Users browsing this thread: 1 Guest(s)