i search since 3 days now. I want to verify that if condition1 AND condition2 is true OR condition3 AND condition4 is true, my test is Ok.
this code doesn't return error, the test runs passed but doesn't return the good message. it return "KO, the color doesn't match with the status." instead of O"OK, the color is red and the status is NOK." And i think that if the status doesn't match with the color, the test will be passed too (??)
Thanks for your help.
Isabelle.
you can answer in french !!
`//1 store the value of the status String DisplayedStatus = driver.findElement(By.xpath("//span[@class='eaDetails-ContentRegion-statustext']")).getText(); System.out.println("the status displayed is: " + DisplayedStatus);
//2 store the color of the bar
String ColorRed = "rgb(227, 34, 25)";
System.out.println("Red is: "+ColorRed);
String ColorGreen = "rgb(137, 186, 23)";
System.out.println("Green is:"+ColorGreen);
String DisplayedStatusColor = driver.findElement(By.xpath("//div[@class='eaDetails-ContentRegion-bar']")).getAttribute("style");
//System.out.println("Styles of bar is: "+DisplayedStatusColor);
// keep bgcolor only
String BgColor1 = DisplayedStatusColor.split("background-color:")[1];
//System.out.println("Color of bar is: "+BgColor1);
String BgColor = BgColor1.split(";")[0]; // remove the semi comma
System.out.println("Color of bar is: "+BgColor);
// check that "the bar is red and the status is NOK" or "the bar is green and status is OK".
// assertTrue((BgColor.compareTo(ColorRed) == 0)&&(DisplayedStatus.compareTo("Status: NOK") == 0));
// assertTrue((BgColor.compareTo(ColorGreen) == 0)&&(DisplayedStatus.compareTo("Status: OK") == 0));
if((BgColor.compareTo(ColorRed) == 0)&&(DisplayedStatus.compareTo("Status: NOK") == 0)){
System.out.println("OK, the color is red and the status is NOK.");
}
else {
if((BgColor.compareTo(ColorGreen) == 0)&&(DisplayedStatus.compareTo("Status: OK") == 0)){
System.out.println("OK, the color is green and the status is OK.");
}
System.out.println("KO, the color doesn't match with the status.");
}
}`
Aucun commentaire:
Enregistrer un commentaire