Quality is delighting customers
Tags:
there are different ways that you can check outcome with expected result.
WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com/"); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhere FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
Hopefully this helps you.
Would accept if there are any other ideas. Thanks
Happy testing
Sam
Thanks sam for your response. I think Assertion is good approach.
Hi pankaj,
By using if condition it is possible, if the test case is pass it will go to if statement and if the test case is fail it will go else statement. If you want to print the error u can use try catch in else statement or you can use take screenshot method.
for example:
public void test(){
WebElement submit = driver.findElement(By.id(""));
if(submit.isDisplayed()){
System.out.println("submit button is displayed");
} else {
try{
} catch(Exception e){
e.printStackTrace();
System.out.println("submit button is not displayed displayed");
ExcelPaths.takeScreenshot(driver, "D:test//test.jpg");
}
}
}
public static void takeScreenshot(WebDriver driver, String FilePath) throws Exception {
TakesScreenshot SCRShot = ((TakesScreenshot)driver);
File FileScr = SCRShot.getScreenshotAs(OutputType.FILE);
File DestiFile = new File(FilePath);
FileUtils.copyFile(FileScr, DestiFile);
}
correct me if am wrong means...........:-)
© 2019 Created by Quality Testing.
Powered by