How to perform on error close browser event?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to perform on error close browser event?
Hi There
There is a annotation of @Before and @After(teardown) in Cucumber-JVM framework, which closes all the browsers on error. I am looking for the similar action in testComplete. The closest one is one on error control property. However, I am not sure if that is the right one to use for following reasons:
1. It seems tie to certain tests -- There are many different errors in tests. Object not find, time out, value not show....I need a way to close browser on any Log.error.
2. Have trouble to understand how to use it. e.g. function EventControl1_OnLogError(Sender, LogParams){}
How to pass sender, and logParams passed?
3. It would be helpful if someone can give me a example for how to implement the global teardown action.
Thanks!
Grace
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Grace,
You may consider OnStopTest/OnStopTestCase events.
For the general description of TestComplete events see https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/about.html, https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handl... and related help articles.
P.S. I am not a fan of 'browser restart for every test' approach from unit/integration tests world to be used in the world of functional end-to-end tests, but this is off topic.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alex
Thanks for your replying.
I have trouble to understand how to implement the event. I am using the script mode.
Let's say I added the EventControl1_OnStopTest(Sender) in one of my test.
1. How the sender variable being? Should I pass the wording in all my Log.Message?
2. The purpose of closing the browsers on error is trying to put the next test in the same starting point. I don't know what and when the errors occur, therefore I need to close the current browser so that my next run can continue. If the Event tie to the specific tests I am wondering how it serves my purpose.
Thanks,
Grace
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Grace,
> I have trouble to understand how to implement the event.
Have you went through the https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handl... help article?
> If the Event tie to the specific tests [...]
Events handling is project-wide. Parameters provided to the handler routine are provided by TestComplete and are described in the help topic devoted to the given event (OnLogError, OnTestStart, ...)
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I did.
When I added the onStopTest event control the popup ask you to select a test. It adds a function to that test script.
I added content.
function EventControl1_OnStopTest(Sender)
{
let browser = Aliases.browser;
browser.Close();
}
At project level when I run the item I select the event/mehod.
What is the sender parameter should it be? I don't any parameters. I am using script mode.
Thanks!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Alex!
I tried on my script with the event control it worked. Just I don't know why it didn't work in project execution.
Thanks for your help!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Grace,
Good to know that the problem is solved.
> What is the sender parameter should it be?
As it is documented, this can be considered as internal parameter provided by TestComplete and one should not bother about it in test script code.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
