try{
WebElement element = driver.findElement(By.xpath("//html/body/table[2]/form/table/tbody/tr/td/font"));
String strngAcc = element.getText();
System.out.println(strngAcc);
AssertJUnit.assertEquals("Account Information Created Successfully",strngAcc);
}
catch(WebDriverException ex) {
// Take **Screen Shot** here by Calling ScreenShot Capture Method
ScreenShot.takeScreenShot(driver, "AccountTest", "createAccount");
}
and ScreenShot Method is as below which Is used for Both Sequential Execution and Parallel Execution
static Properties prop = null;
public static void takeScreenShot(WebDriver driver, String className,
String methodName) {
try {
prop = PropertiesLoader.getPropertiesLoader();
File scrnsht=null;
String isSequential = prop.getProperty("isSequential");
if (isSequential.equalsIgnoreCase("true")) {
scrnsht = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
} else {
WebDriver augmentedDriver = new Augmenter().augment(driver);
scrnsht = ((TakesScreenshot) augmentedDriver)
.getScreenshotAs(OutputType.FILE);
}
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy/MMM/dd HH:mm:ss");
String date = formatter.format(currentDate.getTime()).replace(
"/", "_");
String dateFormatetd = dateN.replace(":", "_");
FileUtils.copyFile(scrnsht, new File(
"D:\\SeleniumScreenShots\\" + className + "\\"
+ methodName + dateFormatted + ".png"));
P.S : The ScreenShot Capture Used here is Driver Level and Not the Desktop Level