I am trying to port some of my WebDriver tests from JAVA to C#. What I'm stuck on is the situation when the driver cannot find some element on the page, in JAVA I do :
if (second >= 10) fail("timeout - " + list);
so if something takes more than 10 seconds the test fails with the timeout message. I tried a similar approach in C# with
if (sec >= 10) Debug.Fail("timeout : " + vList);
but this actually did not fail the test, but gave me an option to do so with the exception message box. That was a no no, I need my automatic test to fail outright on its own. Then I tried
if (sec >= 10) Assert.Fail("timeout : " + vList);
but this is throwing an unhandled exception error. Should I enclose the Assert.Fail in try/catch block? Or should I use something completely different to fail the test?
I am using MSTest, as mentioned in the topic.
EDIT: The exact message is :
AssertFailedException was unhandled by user code. Assert.Fail failed. timeout : someField.
on
Assert.Fail("timeout : " + vList);