Assert vs Verify in C#

4,939 views
Skip to first unread message

dt_nz

unread,
May 8, 2012, 6:25:37 AM5/8/12
to Selenium Users
Hi,
I am new to C# and selenium, (previoulsy used watir and ruby).

I cannot seem to find any way to Verify results using C#, as opposed
to Assertions which stop the rest of the test executing. I noticed on
the selenium website that there is this capability.
Does anyone have any experience with this.

Moises Siles

unread,
May 8, 2012, 1:02:36 PM5/8/12
to seleniu...@googlegroups.com
I think you should need some test framework like nunit, mstest, mbunit


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


MArk B.

unread,
May 8, 2012, 1:13:35 PM5/8/12
to Selenium Users
On May 8, 10:02 am, Moises Siles <moises.si...@gmail.com> wrote:
> I think you should need some test framework like nunit, mstest, mbunit

What he said plus you can put in a try-catch around it if you want to.
That can trap the error thrown by the Assert.

Clue us in to what you're using as a framework and/or what your script
structure is and we could help more.

MArk B.

dt_nz

unread,
May 9, 2012, 6:46:32 AM5/9/12
to Selenium Users

I am using Nunit in Visual Studio. I have tried running the tests with
the reshaprper plugin, and the nunit gui with a try-catch but the
assertion failure doesnt get reported at the end.

so for example

try
{

Assert.IsTrue(SetUpBrowser.VerifyTextPresent("bluemoon"));
}
catch (Exception)
{

Console.Write("Test Errored...");
}

The assertion fails, but the report results does not contain the
error.

Let me know if you need more info.

dt_nz

unread,
May 15, 2012, 5:09:51 PM5/15/12
to Selenium Users
Does anyone have any experience with verifys in C#?

Ashok Tulachan

unread,
May 15, 2012, 8:10:06 PM5/15/12
to seleniu...@googlegroups.com
Instead of using Assert or verify, i create custom WaitforIsVisible(#element) method from selenium and use if else statement for my scenarios.
 
Not sure if that will help you.


 
On Tue, May 15, 2012 at 4:09 PM, dt_nz <david....@sungard.com> wrote:
Does anyone have any experience with verifys in C#?
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Regards,
 
Ashok Tulachan
 

Gulshan Saini

unread,
May 16, 2012, 12:41:56 AM5/16/12
to seleniu...@googlegroups.com
You can look at this example in Java and convert it into C#
http://seleniumexamples.com/blog/guide/using-soft-assertions-in-testng/

Thanks
Gulshan

Moises Siles

unread,
May 16, 2012, 9:39:25 AM5/16/12
to seleniu...@googlegroups.com
Did you see the text in the console?

   Console.Write("Test Errored..."); 

Reply all
Reply to author
Forward
0 new messages