public void GivenIEnterToPortalLoginPage() { try { //If user is not logged in, login page is loaded by default loginPage = new Loginpage(driver); loginPage.Reload(); } catch (MissingElementException) { //if user is already logged in then homepage is loaded, so Logout and go to login page PageBase navigationBar = new PageBase(driver); loginPage = navigationBar.Logout(); //dashboardPage = null; } }