How can I pass driver information to OnTestFailure

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How can I pass driver information to OnTestFailure

Venkatesh Singh
How can I pass driver information to OnTestFailure, I require this as I am running tests on Grid and driver information should be passed at runtime.

Is there any method in ITestResult to Achieve this??

Regards,
Venkatesh

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I pass driver information to OnTestFailure

Krishnan Mahadevan
Venkatesh,
You can do the following : 

Get access to the current ITestResult from within the @Test method using 

ITestResult iTestResult = Reporter.getCurrentTestResult();

And then inject the WebDriver instance into the ITestResult as an attribute as shown below.
iTestResult.setAttribute("driver", driver); // Here driver is of type WebDriver (or) RemoteWebDriver.

Now you can retrieve the WebDriver associated with the ITestResult using iTestResult.getAttribute("driver")

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Mar 21, 2017 at 8:26 PM, Venkatesh Singh <[hidden email]> wrote:
How can I pass driver information to OnTestFailure, I require this as I am running tests on Grid and driver information should be passed at runtime.

Is there any method in ITestResult to Achieve this??

Regards,
Venkatesh

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...