For example this simple HTML5 form https://demoqa.com/automation-practice-form
Click Submit, then driver.findElement(By.id("firstName")).getAttribute("class")
would not return ":invalid".
Impossible without JavaScript calls?
For example this simple HTML5 form https://demoqa.com/automation-practice-form
Click Submit, then driver.findElement(By.id("firstName")).getAttribute("class")
would not return ":invalid".
Impossible without JavaScript calls?
Might be possible using the javascript executor: http://infiautomation.blogspot.com/2019/07/working-with-pseudo-elements-in.html
String script = "return window.getComputedStyle(document.querySelector('#test_ID'),':invalid').getPropertyValue('border-color')";
JavascriptExecutor js = (JavascriptExecutor)driver;
String content = (String) js.executeScript(script);
System.out.println(content);
It's really checking the styling rather than if the attribute psuedo class exists. Much like this answer here: https://stackoverflow.com/a/53868324/1387701
var el = document.querySelector('#elt'),
pseudo = window.getComputedStyle(el, ':before');
alert(pseudo.getPropertyValue("content"));