/// <summary> /// Method to fire the Desired Link/Button /// </summary> /// Authour: Vamsi krishna Boyapati /// Date:27th-March-2013 /// <param name="objMySelenium">Selenium RC instance</param> /// <param name="strLocator"> Locator of the Control/Element(Xpath)</param> /// <returns>Boolean value(True/False)</returns> public bool ClickFireEvent(ISelenium objMySelenium, string strLocator) { bool bStatus = true; IWebDriver objMyWebDriver = ((WebDriverBackedSelenium)objMySelenium).UnderlyingWebDriver; try { if (objMyWebDriver.FindElement(By.XPath(strLocator)).Displayed) { objMySelenium.FireEvent(strLocator, "onclick"); } else { bStatus = false; } } catch (AutomationException EX) { Console.WriteLine(EX.Message); } return(bStatus); }
///<summary> /// This method captures the error message displayed when attempts to login with invalid credentials /// <example>CaptureLoginErrorMessage(browser, "ecomm_test_user", "123456")</example> public string CaptureLoginErrorMessage(ISelenium browser, string userName, string password) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; LFcommonObj.selectMenuButton(browser); LFcommonObj.clickObject(browser, LoginLogoutControls.loginOrRegisterLink); LFframeworkCommonObj.WaitUntilElementEditable(browser, LoginLogoutControls.loginUsernameTextBox, "10000"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginBanner), "Login page not displayed"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginUsernameTextBox), "Username field not presesnt in Login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginPasswordTextBox), "Password field not presesnt in Login page"); browser.Type(LoginLogoutControls.loginUsernameTextBox, ""); if (userName != null) { browser.Type(LoginLogoutControls.loginUsernameTextBox, userName); } browser.Type(LoginLogoutControls.loginPasswordTextBox, ""); if (password != null) { browser.Type(LoginLogoutControls.loginPasswordTextBox, password); } browser.FireEvent(LoginLogoutControls.loginSubmitButton, "click"); LFcommonObj.WaitForLoadingIcon(browser, FrameGlobals.IconLoadTimeout); Thread.Sleep(1000); return driver.FindElement(By.XPath(LoginLogoutControls.loginErrorpanel)).Text; } catch (Exception ex) { Console.WriteLine("Function 'CaptureLoginErrorMessage' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); return null; } }
///<summary> /// This method loggsin to the application /// <example>Login(browser, "arun_ecomm_test", "123456") </example> public void Login(ISelenium browser, string username, string password) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; Assert.IsTrue(browser.IsVisible(LoginLogoutControls.LadbrokesHomeLink), "Header(Ladbrokes Logo) is not displayed on Home page"); Assert.IsTrue(browser.IsVisible(BetslipControls.betslipButton), "Betslip button is not displayed on Home page"); LFcommonObj.selectMenuButton(browser); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.logoutLink), "Logout link is present in the sidebar(User Logged in"); LFcommonObj.clickObject(browser, LoginLogoutControls.loginOrRegisterLink); // Check for the Login page elements LFframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.loginUsernameTextBox, FrameGlobals.ElementLoadTimeout.ToString()); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginBanner), "Login header is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.LadbrokesHomeLink), "Ladbrokes Logo is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginUsernameTextBox), "User name field is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginPasswordTextBox), "Password field is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.lostLoginButton), "Lost Login button is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.newToLadbrokesBanner), "New to Ladbrokes banner is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.registerButton), "Register button is not present in mobile's login page"); Assert.IsTrue(browser.IsVisible(BetslipControls.betslipButton), "Betslip button is not present in mobile's login page"); //Login LFcommonObj.EnterField(browser, LoginLogoutControls.loginUsernameTextBox, username); LFcommonObj.EnterField(browser, LoginLogoutControls.loginPasswordTextBox, password); //LFcommonObj.clickObject(browser, LoginLogoutControls.loginSubmitButton); browser.FireEvent(LoginLogoutControls.loginSubmitButton, "click"); LFcommonObj.WaitForLoadingIcon(browser, FrameGlobals.IconLoadTimeout); //Check elements on Login FrameGlobals.ElementLoadTimeout + 10000 //LFframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.balance, 30000.ToString()); //Thread.Sleep(10000); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.balance), "Balance is not displayed on Login"); Console.WriteLine("Login was successful"); } catch (Exception ex) { Console.WriteLine("Function 'Login' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }