How to assert text of webpage using selenium 2.0?
Answer / Raj Bhushan Dube
To assert text on a webpage using Selenium 2.0 (WebDriver), you can use the `getText()` method followed by `assertEquals()` for verification:
1. Get the text from the desired element: `String expectedText = driver.findElement(By.xpath("//your xpath")).getText();`
2. Verify the actual text with the expected text using `assertEquals()`: `assertEquals(expectedText, "Expected Text");`
| Is This Answer Correct ? | 0 Yes | 0 No |
How do you read data from excel?
What the webdriver supported mobile testing drivers do you know?
How do you add check points or verification points in selenium?
How to perform right click action (context click) in selenium webdriver?
Which of the selector ID, name, XPath or CSS should I use?
What are startpoints and breakpoints in selenium?
Differentiate between ‘/’ and ‘//’.
How would you test your element locator?
What is the object repository?
What is the alternative to driver.get() method to open an url using selenium webdriver?
What are the annotations available in testng?
How to find more than one web element in the list?