Is it possible to get a reference of the caller Object from ITestResult ?
My use case is I want to get the reference of TestClass Object and in turn use it to retrieve the Driver Associated with that Test class.
This is what I was trying but it holds only the name of SuperClass and not the Object ref.
I also see that there is a Cast API but it expects the object as a parameter and won't be useful in this case.
Any pointers ?
public synchronized void onTestFailure(ITestResult result) {
result.getTestClass().getRealClass().getSuperclass();
}
what I want to achieve, take screenshot based on the WebDriver that is used by Test Class.
public synchronized void onTestFailure(ITestResult result) {
Superclass a = result.getTestClass().getRealClass().getSuperclass();
//dummy code
WebDriver webDriver =a.getWebdriver()
File scrFile = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);