//Emulate user public string Emulate() { try { Assert.IsTrue(_UserPage.AccountInfo.Click()); Assert.IsTrue(_UserPage.EmulateUserButton.WaitUntilDisplayed()); Assert.IsTrue(_UserPage.EmulateUserButton.Click()); //Loading some time throws 'An error occurred' // Please dont modify below code without considering below logics. // 1. 'An error occurred' - Eumaltion failed. // 2. 'An error occurred' - Eumaltion success. // 3. 'An error occurred' - After long time Eumaltion success. // 4. 'An error occurred' - After long time Eumaltion failed. Thread.Sleep(10000); _UserPage.WaitUntilLoading(); Assert.IsTrue(_UserPage.ShowAccountOptions.WaitUntilDisplayed()); Regex regex = new Regex("Emulating"); Match match = regex.Match(_UserPage.ShowAccountOptions.GetText()); if (match.Success) { return("EmulationSuccess"); } else { return("EmulationFailed"); } } catch { return("EmulationFailed"); } }