How to validate a text (Assert) in a certain field in Selenium Webdriver?

-1

How do I validate a text in a given field?

The location is xpath:

html/body/div[1]/div/div[4]/article/div[1]/div/header/div[1]/h1

The text is " Congratulations! Successfully inserted ".

How do I validate with assert? Java language.

Thank you in advance!

    
asked by anonymous 15.03.2018 / 16:05

1 answer

-1

Oops! Here is the code that can help you:

String textoElement = driver.findElement(By.xpath("html/body/div[1]/div/div[4]/article/div[1]/div/header/div[1]/h1\n")).getText();
        assertEquals("texto-esperado", textoElement);
    
16.04.2018 / 01:58