I have been trying for a while now to use the "Verify" option in Selenium as opposed to the "Assert" option. My thought being that with a Verify option is that my test can be run completely and then to get a list of the errors. In trying to do so I have realized that "code wise" the Verify option is the same as Assert but it is just surrounded by the try-catch block. I have tried various options to make this work, but the issue I am facing is that the test still stops on the statement that breaks as opposed to giving me a list of the errors.
My structure has been:
public class SelTests {
public StringBuffer verificationErrors = new StringBuffer();
public WebDriver driver;
@BeforeTest
public void setup() throws Exception {
// DO SETUP STUFF
}
@Test
public void TestScript1() throws Exception {
try { //assertEquals("string1", "string2") } catch (Exception e) {verificationErrors.append(e.toString());}
try { //assertEquals("string1", "string2") } catch (Exception e) {verificationErrors.append(e.toString());}
try { //assertEquals("string1", "string2") } catch (Exception e) {verificationErrors.append(e.toString());}
@AfterTest
public void tearDown() throws Exception{
driver.close();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
System.out.println(verificationErrorString);
}
}
But even after modifying this in many ways, I still have the same issue. I also tried surrounding the entire block of assert statements instead of individually doing them as in the code above, but nothing works. I knowingly introduces errors in some assertions but each time I get the log of just 1 error.
Environment:
Selenium 2.30 Server-standalone
TestNG annotations and frameworks
Java code using WebDriver implementations
Eclipse
Windows 7 - 64bit (this should not matter though)
Any help in guiding me to achieve what I am trying to implement will be greatly appreciated.
Thanks,
Alister