adspace


How to assert text of webpage using selenium 2.0?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What’s selenese?

920


what will be the first salary and what will be the hike in the salary?

929


Do you know how to locate a link using its text in selenium?

985


Have you created any framework?

1038


How can you fetch an attribute from an element? How to retrieve typed text from a textbox?

1197