- Pilot_RiazRegular Participant
- Posts : 27
Join date : 2011-08-24
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
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
- faramkaProfessional
- Posts : 143
Join date : 2011-09-15
Location : Poland
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):
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_RiazRegular Participant
- Posts : 27
Join date : 2011-08-24
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?
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?
- faramkaProfessional
- Posts : 143
Join date : 2011-09-15
Location : Poland
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
Maybe here you will find the answer.
Maybe here you will find the answer.
- Pilot_RiazRegular Participant
- Posts : 27
Join date : 2011-08-24
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
Code is:
bool isSayHelloExist = selenium.IsTextPresent("sayhello");
if (isSayHelloExist) {
Console.Out.Writeln("text is present"); }
else {
Console.Out.Writeln("text is not present") }
Thanks for help in the right direction
Code is:
bool isSayHelloExist = selenium.IsTextPresent("sayhello");
if (isSayHelloExist) {
Console.Out.Writeln("text is present"); }
else {
Console.Out.Writeln("text is not present") }
- webdriver + python, how to check for presence of text on page?
- Finding and Verifying Text in a Table that is in no particular order
- How to check the whether the text present in the page or under particular area or not in Webdriver
- Text Box Data Clears When Page Submitted
- Selenium Automatically clears the text entered in text box-Dynamic Web Table(dgrid)
Permissions in this forum:
You cannot reply to topics in this forum