Hi,
we are currently facing an issue with the following scenario.
We use excel to test multiple logins
In a specific scenario an error message is displayed (when using a specific user), when the error message is displayed we want the test to break. I tried the logical steps but it did not work for me.
I then created my own coded step.
What it does is it has an if else statement, but as soon as the step is reached the error has not yet been thrown. So I then get the Element not found error.
I don't want an error to be thrown as this is the functionality is correct. However when the test is rerun with the new user name and password, we want it to break.
So here is my problem.
string userLogedin = Data["userName"].ToString();
try
{
bool Error = true;
Error = Pages.Page.errorMessage.IsEnabled;
if (Error == true)
{
Console.WriteLine("an error occured in the tests");
Console.ReadLine();
Log.CaptureBrowser(ActiveBrowser, "C:\\Users\\user\\Pictures\\Page"+DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ffff")+".png", true);
Log.WriteLine(LogType.Error, "Login failed");
}
else
{
Element ErrorMessage = Manager.ActiveBrowser.Find.ById("ctl00_maincontent_lblHeader");
Assert.IsNull(ErrorMessage);
}
}
catch
{
}
Now using this code, it works correctly for the user who does not get the error, but when the user comes in where the error should be displayed it does not fail the test.
This part
Log.WriteLine(LogType.Error, "Login failed");
Does not seem to work.
I keep getting an error that it is trying to convert it to a exception.
So I am in a catch 22 situation.
The test that should succeed, succeeds. The test that needs to fail, succeeds.
The test that should succeed, fails. The test that needs to fail, fails.
Can you please point me into the right direction? this is rather critical, as this will be the base for check where elements are not available in certain scenario's.
Thank you in advance.