Reputation: 591
I have a Selenium suite testing my (web) user interface and I'm trying to prove that the appropriate error messages appear when a User puts in invalid values.
<input id="inputID" type="number" min="1" step="1" />
WebElement element = webDriver.findElement(By.id("inputID"));
element.click();
element.sendKeys("-2");
element.??????
It's trivial to do by hand, but for the life of me I can't figure out how to test that the input:invalid
CSS is applied or how to read/test the tooltip value.
It would probably be sufficient to prove that the field is marked as invalid, even if we don't test the content of the tooltip, though ideally we'd test both.
Upvotes: 0
Views: 70
Reputation: 591
I was able to test for styling using the command
element.getCssValue("border-bottom-color");
Note:
Testing for styles related to the border must specify a side, since styles that apply to all four sides is short hand that is broken out into styling for each side. border:blue
will be erased and replaced by border-bottom-color:blue
, border-top-color:blue
, border-right-color:blue
, and border-left-color:blue
Upvotes: 1