I need to check the text of the error that is issued after the field is not filled / not correctly filled

I can’t specify the path to the input_error element (there may be a dozen more on the page)

<div class="form_controls"> <input id="email" class="input_text" type="text" name="email"> <div class="input_error">Укажите email</div> 

    1 answer 1

     List<WebElement> inputs = driver.findElements(By.xpath(".//div[@class='form_controls']/div[@class='input_error']")); 

    I advise you to read here , here , here and any query in google such as selenium java example / selenium java example селениум примеры java

    • I have already seen the first link, according to your example path, I tried to write the text "Specify email" in the variable. String errorMail = driver.findElement (By.xpath (".// div [@ class = 'form_controls'] / div [@ class = 'input_error'] ")). getText (); but I get an error that I can not find the element - Dmitry Feniks
    • Well, then you have to look for the item differently. See what is unique, and then specify this xpath / class / id, etc., etc. - Andrew Bystrov
    • unique id that goes over the right class and for - Dmitry Feniks
    • what for? Did you mean the form_controls class? - Andrew Bystrov
    • everything turned out to be very simple ... I could find the element, I just worked through the test before it could appear ... I added a wait until the element appeared and now everything passes. - Dmitry Feniks