package playground; import com.google.common.util.concurrent.Uninterruptibles; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.time.Duration; public class VerifyText { private WebDriver driver; @BeforeClass public void StartSession() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://localhost:3000/verifytext"); } @AfterClass public void CloseSession() { Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(3)); driver.quit(); } @Test public void test01_verifyTest() { // driver.findElement(By.xpath("//span[.='Welcome UserName!']")); WON't WORK String normal_text=driver.findElement(By.xpath("//span[normalize-space(.)='Welcome UserName!']")).getText(); System.out.println("Normalized Text: "+normal_text); Assert.assertEquals(normal_text,"Welcome UserName!"); } }