public void verifyErrorMsgforInvalidUserTransPosting(
{
String errorMSG="You dont have permission to create transaction using this ID";
String errorMSGSYS=driver.findElement(By.xpath("html/div/.....").getText();
if(errorMSGSYS.equals(errorMSG))
{
System.out.println("System didnt allowed user to post the Transaction");
report.updateTestLog("Verify System is NOT allowing user to post transaction for an invalid user", "System didnt allowed user to post the Transaction", Status.SCREENSHOT);
}
else
{
System.out.println("System is allowing user to post the Transaction which is NOT expected behavior");
report.updateTestLog("Verify System is NOT allowing user to post transaction for an invalid user", "System is allowing user to post the Transaction which is NOT expected behavior", Status.FAIL);
}
}
In dem obigen Code, wenn (Bedingung 1) funktioniert, wenn das Element gefunden wird, und wenn die condition1 erfüllt else-Anweisung funktioniert, wenn eine Nichtübereinstimmung gibtHandhabung try catch für eine if-Anweisung in Selenium WebDriver
istKönnte mir jemand helfen, wie kann ich mit dem else umgehen, wenn das Element NICHT mit try catch oder einer anderen Methode gefunden wurde?
Vielen Dank .... Das hat für mich funktioniert ... Happy :) :) :) – Meghasri