sel.scone
unread,Nov 12, 2012, 9:50:18 PM11/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to seleniu...@googlegroups.com
I am currently driving my Selenium-Webdriver tests using TestNG and I am planning to run them in parallel in the future using TestNG's parallel option.
Currently, my driver (firefox, ie, etc.) is created in @BeforeMethod. I would like to take a screenshot of my test if it fails. I know one way to do it is to have ITestResult as a parameter of your @AfterMethod, then in your @AfterMethod, check if the result is failure and take a screenshot using your driver if it is. However, I do not want to keep repeating that conditional check (whether test result is failure) in every one of my @AfterMethod (Imagine I have 20 test classes and each one of them has @AfterMethod). An idea I have is to implement ITestListener and take a screenshot in method onTestFailure().
However, I am not familiar with multi-threading at all, and currently my driver is not globally accessible/is instance-based (i.e. I don't have for example, a static method like DriverManager.getDriver() to access/get my driver). My question is, if I change my code and make my driver global, and use it to take a screenshot in the onTestFailure() method of my listener class, is the driver/my test/screenshot going to be all confused when I run my tests in parallel using TestNG?
Thanks a lot in advance!