Reputation: 625
I am using selenium using java. I am new to selenium. I have a class named connected which contains a symbol with green.I want to assert that if the symbol turned to green or not.
Here is my code:-
Boolean connectionSymbolGreenValue = driver.findElement(By.className("connected")).isEnabled();
System.out.println("Green Signal"+connectionSymbolGreenValue);
Assert.assertTrue(connectionSymbolGreenValue);
I have tried this code. If condition Fails then also it is returning true. Is there any error in my code? Can anyone suggest any solution?
Upvotes: 0
Views: 867
Reputation: 193368
As you are trying to identify a class named connected which contains a symbol with green invoking .isEnabled()
method may not solve our purpose.
.isEnabled()
.isEnabled()
validates if the element currently enabled or not? This will generally return true
for everything but disabled input elements.
Try to identify an attribute(style) which uniquely identifies the attribute_containing_greenness_value
of the symbol, then extract the String
value and invoke Assert.assertTrue()
comparing with actual_greenness_value
as follows :
String connectionSymbolGreenValue = driver.findElement(By.className("connected")).getAttribute("attribute_containing_greenness_value");
System.out.println("Green Signal"+connectionSymbolGreenValue);
Assert.assertTrue(connectionSymbolGreenValue.equalsIgnoreCase("actual_greenness_value"));
Upvotes: 4