Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

I am having trouble verifying text on the web page Empty I am having trouble verifying text on the web page

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
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

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

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");
}
avatar
Pilot_Riaz
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-08-24

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

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?
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

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

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

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

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

I am having trouble verifying text on the web page Empty 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