tags:

views:

108

answers:

1

Hello,

I was just trying to perform a task after i stop the test run in QTP.

The actual scenario is like this:

I want to login into some site(project internal), perform some task and when i stop the test run, it should automatically logoff from the site.

There is a logoff button too on the web page.

But the challenge is that we have to logoff after we stop the test not before stopping the test run.

kindly help me out, i tried a lot but i am not able to do that.

Thanks in advance.

+1  A: 

I'm not sure I understand why you would want to log off after the test stops, why not have the final step of the test log off?

Also from your question it sounds like you're talking about manually stopping the test

when i stop the test run, it should automatically logoff from the site

This seems to be an un-interesting case, if you're manually stopping the test then you can manually log-off and for automatic test runs (which is the point of automatic testing) behave as is required (log off at the last step etc.)

QTP does support closing a browser after the test run (when the test is closed) this is done from the Record and Run Settings dialog.

All that being said here's a hacky way to get what (I think) you're looking for, have this as the last step of your test:

Browser("Br").Navigate "javascript:setTimeout('document.getElementById(""logout"").click();', 5000); void(0)"

What this does is tell the browser to call a specific function after 5 seconds (5000 milliseconds) (using a bookmaklet), the code being called after 5 seconds clicks on the log off button (you'll have to use the correct id or otherwise locate the button of course).

As I said I'm not sure I understood your problem so I don't know how helpful this will be.

Motti