Matching any text present on the visible html page
Suppose I have an add question facility but can't add same question in the form. So need to check whether the question is already visible on the screen, if not then add it.
I am not getting how to match a string value to the content of a form. is it possible to do so with selenium webdriver. Or if there is any other way to achieve this? I just need to check a text whether displayed on the screen or not.
When you use
driver.getPageSource()it gives you entire page source. To be more efficient, use something like this:
WebElement element = driver.findElement(By.xpath("//*[contains(.,.)]"));