Share
Go down
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

I am having trouble verifying text on the web page

on Wed Nov 23, 2011 3:51 pm
Hi,

I've just started using C#, NUnit and Selenium

On the web page i am testing i want to verify some text is present on the page. E.g. Company Name is shown at the top of the home page

I use the command selenium.IsTextPresent("Company Name");

I compile it, run it with NUnit it works fine.

I wanted to see it fail if it does not find the text present. So i try
selenium.IsTextPresent("sayhello");

I know "sayhello" is definetely not present on the web page. NUnit should fail on this bit.

When i look at the TestResult file from NUnit it does not say it failed.

That means anything will pass whatever text i verify for by using selenium.IsTextPresent. This not correct.

What command can i use to verify the text properly? If some text doesn't exist on the web page NUnit should put a fail in the TestResult file so i know it has failed on that step

regards, Riaz


Last edited by Pilot_Riaz on Wed Nov 23, 2011 5:01 pm; edited 1 time in total
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

Re: I am having trouble verifying text on the web page

on Wed Nov 23, 2011 3:58 pm
In PHPUnit I have got assertTextPresent() - it returns boolean value and throw error (test fails) when the result is "false".

You can do it in this way (code is in PHP):
Code:
if ($this->isTextPresent("blablabla") {
    $this->fail("the text is not present at this page");
}
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

Re: I am having trouble verifying text on the web page

on Wed Nov 23, 2011 7:40 pm
In C# i am trying

bool isSayHelloExist= selenium.IsTextPresent("sayhello");

if (isSayHelloExist)

{ }

else { }

If the value is false how can i print that the value is false to the console or Nunit testResult file?
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

Re: I am having trouble verifying text on the web page

on Wed Nov 23, 2011 7:55 pm
I think you have to read the documentation Smile
Maybe here you will find the answer.
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

Re: I am having trouble verifying text on the web page

on Thu Nov 24, 2011 5:08 pm
I have it working now. The output text is not present is showing in the Output window in NUnit when the text is not present on the web page.

Thanks for help in the right direction Smile

Code is:

bool isSayHelloExist = selenium.IsTextPresent("sayhello");

if (isSayHelloExist) {
Console.Out.Writeln("text is present"); }


else {

Console.Out.Writeln("text is not present") }
Sponsored content

Re: I am having trouble verifying text on the web page

Back to top
Permissions in this forum:
You cannot reply to topics in this forum