我想知道如何使用selenium webdriver查找html5输入框的错误消息文本?

<input class="_input--inputElement--2mQgjB0b theme--inputElement--2WvFsoYo" role="input" type="text" value="" xpath="1">
<span class="_input--bar--1Z4XOfUq theme--bar--fT1WI7br" xpath="1"></span>
<span class="_input--error--1ss75RVV theme--error--1p4yC2ps" xpath="1">Required</span>
我尝试了不同的方法,但似乎都不起作用!
String Emessage = Driver.driver.FindElement(By.XPath("//span[contains(text(),\'Required\')]")).getAttribute("Required");
String Emessage = Driver.driver.FindElement(By.XPath("//span[contains(text(),'Required')]")).Text;发布于 2020-04-16 03:03:04
在Xpath中尝试一下- "//*contains(@class,'_input--error')和contains(@class,‘theme-error’)“
https://stackoverflow.com/questions/61164972
复制相似问题