views:

897

answers:

3

I am using Selenium IDE to record some scenarios and wanted to check if a particular text is present on the page. I inserted a command "VerifyTextPresent". However, it always returns the result as true even when the particular text is not present.

What can be the probable reason? Do I need to modify anything?

A: 

Selenium assertions have different modes:

All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure.

Try assertTextPresent. This should abort the test immediately.

Thomas Jung
Still not working. :(Somehow the test is still getting pass.
Aditya
The problem is, it is not logging failure even when it should fail...
Aditya
Please post your test code and page.
Thomas Jung
Why are you downvoting? I try to figure out what's going on without a page and test code.
Thomas Jung
Hi Thomas, I didn't down vote... I will post the test code.
Aditya
<tr> <td>open</td> <td>/logins</td> <td></td></tr><tr><td>type</td> <td>login_username</td> <td>abc</td></tr><tr> <td>type</td> <td>login_password</td> <td>pqr</td></tr><tr> <td>clickAndWait</td> <td>//input[@value='Sign In']</td> <td></td></tr><tr> <td>verifyTextPresent</td> <td></td> <td>XYZ</td></tr></tbody></table></body></html>Please see if anything is wrong...
Aditya
Could you paste/link to your page? Or search for "XYZ" in the page source. Please use assertTextPresent to rule out that problem.
Thomas Jung
Well, the page is on our local server and hence won't be accessible. I searched for XYZ in he page source and it is not present. Also checked with AssertTextPresent.
Aditya
Does the assertTextPresent work in any test? Could you replace it with a assertTextNotPresent to see if assertions work at all.
Thomas Jung
Seems like the results are getting reversed. I used assertTextNotPresent and the test failed though it should have passed. I could not find any XYZ on page so the test should have passed... but it failed. Really don't understand what's happening... :(
Aditya
Probably you're looking at the wrong page source. Are you sure that you're not looking at the runner frame source code?
Thomas Jung
+1  A: 

Looking at the sourcecode it looks like you are putting the text you are searching for in the incorrect field. verifyTextPresent (and assert...) has only two parameters unlike verifyText which also requires a target.

Unlike verifyText the text element you are searching for should be entered into the second field 'Target' not in 'Value'.

thus the code becomes

<tr>
<td>verifyTextPresent</td>
<td>XYZ</td>
<td></td></tr>

I made the same mistake when learning Selenium as the field names are misleading!

ulkash
A: 

I am learning selenium.how can i locate any object on page

POOJA