Professional Documents
Culture Documents
JH_Base.captureScreenshot(driver, "MYimage");
driver.findElement(By.xpath("//div[@id='gs_lc0']/input")).sendKe
ys("Selenium");
JH_Base.captureScreenshot(driver, "selenium");
driver.findElement(By.xpath("//div[@id='sblsbb']/button")).click
();
JH_Base.captureScreenshot(driver, "button");
driver.findElement(By.xpath("//ol[@id='rso']/div/div/div/h3/a"))
.click();
JH_Base.captureScreenshot(driver, "page");
driver.findElement(By.xpath("//li[@id='menu_projects']/a")).clic
k();
JH_Base.captureScreenshot(driver, "Projects");
driver.findElement(By.xpath("//li[@id='menu_documentation']/a"))
.click();
JH_Base.captureScreenshot(driver, "documentation");
driver.findElement(By.xpath("//li[@id='menu_support']/a")).click
();
JH_Base.captureScreenshot(driver, "Support");
driver.findElement(By.xpath("//a[contains(text(),'dfdAbout')]"))
.click();
}
@AfterMethod
public void tearDown(ITestResult result){
if(ITestResult.FAILURE==result.getStatus()){
JH_Base.captureScreenshot(driver, result.getName());
}
}
}
public static void captureScreenshot(WebDriver driver, String SH ){
try {
TakesScreenshot TS = (TakesScreenshot)driver;
File Source = TS.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(Source, new File("./Screenshots/"+SH+
".png"));
} catch (Exception e){
Reporter.log("Failure to take screenshot and the reason
is:: "+e.getMessage());
}
}