1

I wrote a simple try/catch to validate the title of the login page. At the moment the Title is wrong, so it should go to catch it, but it doesn't. Am I missing something? The page title should be AppGo.

Here is the code:

string getTitle = driver.Title;
try
{
    if (getTitle == "AmazingApp")
    {
        Console.WriteLine("The application " + getTitle + " has logged in successfully!");
    }

}
catch(Exception ex)
{
    Assert.Fail(ex.Message);
    Console.WriteLine("The user failed to log in successfully!");
}
itsMasoud
  • 1,335
  • 2
  • 9
  • 25
Butler
  • 47
  • 6
  • 1
    if there is any exception then it'll go to catch block, your code not throwing any error that's why it's not going to catch block. use, else statement to log your message. – A_Sk Nov 04 '19 at 11:46

0 Answers0