Selenium RC IstextPresent Problem, want to know the actual text present when istextpresent fails
I am using selenium RC with java
I am verifying a text which is present on a webpage like isTextPresent("hello how r u") and suppose it returns false which means sel开发者_开发问答enium was not able to find the given text. My problem is that i Want to know what actual text it finds in place of given text. the text which i verify and the actual text are not completely different string they differ by a character or a word like verify text is hello how r u and actual text was hello where r u is there any way by which i can get this actual text using my verify text using selenium commands
verifyTrue(selenium.isTextPresent("hello how r u")) is used to check whether the text is present in the webpage or not. It does not find any actual text in any location of webpage. It just searches in the webpage for the text we mention(Expected Text). Always its possible to check whether the actual text is present in the particular location of a webpage or not through element locators like xpath.
Your question is unclear...based on my understanding you seem to be looking for
String retrieved_text = selenium.getText("<locator>");
where <locator>
is used to identify the widget from where the text is to be retrieved (xpath, css, etc.)
Once retrieved, you can use the content of retrieved_text
to validate against the expected result, and then enforce your test logic
精彩评论