In the below image, there is an h1 tag. Text says, your policy number is ******. Here, Every-time when i run a new test-case, policy number will change. To get that policy number in testng output. What i need to use the code. I mean how can i getText()
You can fetch the element by its xpath and then get the text from it. You can do it like:
driver.findElement(By.xpath("//div[@class='columns large-8']//h1[@class='fontFamily-1']")).getText()