///<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); } }
///<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 checks for the existance of an element(button, link..) /// <example>CheckElementPresent(browser, xPath)</example> public void CheckElementPresent(ISelenium browserObj, string strLocator) { try { WaitForLoadingIcon(browserObj, Convert.ToInt32(FrameGlobals.IconLoadTimeout)); Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); } catch (Exception ex) { Console.WriteLine("Function 'CheckElementPresent' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method clicks on any desired object(button, link) /// <example>clickObject_MobileLobby(browser, xPath)</example> public void clickObject_MobileLobby(ISelenium browserObj, string strLocator) { try { Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); browserObj.Focus(strLocator); browserObj.Click(strLocator); WaitForLoadingIcon_MobileLobby(browserObj, Convert.ToInt32(FrameGlobals.IconLoadTimeout)); } catch (Exception ex) { Console.WriteLine("Function 'clickObject' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method Clicks on the NRF links and validates the URl opened in the new browser /// <example>ValidatePopupsofNFR(MyBrowser, "xPath", "Ladbrokes LBR", "https://www.gibraltar.gov.gi/remotegambling"); public void ValidatePopupsofNFR(ISelenium browser, string xPath, string newWindowTitle, string expURL) { try { browser.Click(xPath); HGframeworkCommonObj.PageSync(browser); HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000"); Thread.Sleep(1000); Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link"); Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container"); Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container"); browser.Click(LoginLogoutControls.CloseButtonInAlertContainer); HGframeworkCommonObj.PageSync(browser); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button"); browser.Click(xPath); HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000"); Thread.Sleep(1000); Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link"); browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer); HGframeworkCommonObj.PageSync(browser); Thread.Sleep(2000); HGFcommonObj.SwitchWindow(browser, newWindowTitle); string actUrl = browser.GetLocation(); // url = driver.Url; browser.Close(); browser.SelectWindow("null"); Thread.Sleep(1000); if (actUrl.ToLower().Trim() != expURL.ToLower().Trim()) { Console.WriteLine("Mismatch in URL's. Actual '" + actUrl + "', Expected '" + expURL + "'."); } } catch (Exception ex) { Console.WriteLine("Function 'ValidatePopupsofNFR' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method navigates to the Registration page /// <example>NavigateToRegistrationPage(browser) </example> public void NavigateToRegistrationPage(ISelenium browser) { try { MLcommonObj.selectMenuButton(browser); MLcommonObj.clickObject(browser, LoginLogoutControls.loginOrRegisterLink); // Check for the Login page elements MLframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.registerButton, FrameGlobals.ElementLoadTimeout.ToString()); clickObject_MobileLobby(browser, LoginLogoutControls.registerButton); // check for the floowing elements Assert.IsTrue(browser.IsVisible(MobileLobbyControls.Logo), "Ladbrokes Logo was not found on the Registration page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Failed to navigate to Registration page, Registration title not found"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.closebutton), "Close button was found on the Registration page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.licenseText), "Lisence text was not found on the Registration page"); Console.WriteLine("Successfully navigated to Lobby registration page"); } catch (Exception ex) { CaptureScreenshot(browser, ""); Console.WriteLine("Function 'NavigateToRegistrationPage' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
/// <summary> /// This method will wait for loader icon to complete loading /// </summary> /// <param name="browserObj">Browser Instance</param> /// <param name="timeout">Timeout in seconds</param> /// <example>WaitForLoadingIcon(browser,60)</example> public void WaitForLoadingIcon(ISelenium browserObj, int timeout) { IWebDriver driver = ((WebDriverBackedSelenium)browserObj).UnderlyingWebDriver; //CFframeworkCommonObj.PageSync(browserObj); DateTime now; DateTime delay1 = DateTime.Now.AddSeconds(timeout); while (browserObj.IsVisible(LoginLogoutControls.loadingIcon1)) { now = DateTime.Now; if (now < delay1) { continue; } else { break; } } DateTime delay2 = DateTime.Now.AddSeconds(timeout); while (browserObj.IsVisible(LoginLogoutControls.loadingIcon2)) { now = DateTime.Now; if (now < delay2) { continue; } else { break; } } DateTime delay3 = DateTime.Now.AddSeconds(timeout); while (browserObj.IsVisible(LoginLogoutControls.loadingIcon3)) { now = DateTime.Now; if (now < delay3) { continue; } else { break; } } CFframeworkCommonObj.PageSync(browserObj); TimeSpan ts = new TimeSpan(0, 0, 0); driver.Manage().Timeouts().ImplicitlyWait(ts); if (browserObj.IsElementPresent(LoginLogoutControls.InfoPageCloseBtn)) { browserObj.Click(LoginLogoutControls.InfoPageCloseBtn); } }
///<summary> /// This method selects avalue from list/combo box /// <example>SelectValueFromListbox(browser, xPath, value)</example> public void SelectValueFromListbox(ISelenium browserObj, string strLocator, string value) { try { CFframeworkCommonObj.PageSync(browserObj); Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); string[] itemArray = browserObj.GetSelectOptions(strLocator); for (int i = 0; i < itemArray.Length; i++) { if (itemArray[i].ToLower().Trim() == value.ToLower().Trim()) { browserObj.Select(strLocator, value); CFframeworkCommonObj.PageSync(browserObj); break; } else { if (i == itemArray.Length - 1) { Console.WriteLine(value + " not found in the list box"); Fail(value + " not found in the list box"); } } } } catch (Exception ex) { Console.WriteLine("Function 'SelectValueFromListbox' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
/// <summary> /// Method to update and validate Selection status validation /// </summary> public void SelectionStatusValidation(ISelenium browser, ISelenium adminBrowser, TestData testData, string navPanel,string eventName) { string selectionId = string.Empty; try { btCommonObj.AddAndVerifySelectionInBetslip_HR(browser, testData.ClassName, navPanel, testData.ClassName, testData.TypeName, testData.SubTypeName, testData.EventName, testData.MarketName, testData.SelectionName, testData.Odds, false, false); selectionId = testRepositoryCommonObj.GetSelectionIDFromBetslip(browser, testData.SelectionName, testData.EventName); adminCommonObj.UpdateSelection(adminBrowser, selectionId, testData.Odds, "Suspended", ""); Thread.Sleep(FrameGlobals.OpenBetReflectTimeOut); btCommonObj.NavigateToEventDetailsPage(browser, testData.ClassName, navPanel, testData.ClassName, testData.TypeName, testData.SubTypeName, eventName, testData.MarketName); Assert.IsFalse(browser.IsVisible("//div[@class='bxcl bg2 mb4' and contains(string(),'" + testData.SelectionName + "')]//a"), "Selection is not displayed in the event details page"); Console.WriteLine("" + eventName + " selections were suspended and updated in event details page navigated through Today tab from Hr home page"); } catch (Exception ex) { Console.WriteLine(ex.Message); CaptureScreenshot(browser, "SelectionStatusValidation"); } finally { adminCommonObj.UpdateSelection(adminBrowser, selectionId, testData.Odds, "Active", ""); } }
/// <summary> /// This method will wait for loader icon to complete loading /// <param name="browserObj">Browser Instance</param> /// <param name="timeout">Timeout in seconds</param> /// <example>WaitForLoadingIcon(browser,60)</example> public void WaitForLoadingIcon_MobileLobby(ISelenium browserObj, int timeout) { MLframeworkCommonObj.PageSync(browserObj); DateTime now; DateTime delay = DateTime.Now.AddSeconds(timeout); while (browserObj.IsVisible(MobileLobbyControls.lbLoadingIcon)) { now = DateTime.Now; if (now < delay) { continue; } else { break; } } MLframeworkCommonObj.PageSync(browserObj); }
///<summary> /// This method verifies the details, links once the user has logged out /// <example>VerifyDetailsOnLogout(browser)</example> public void VerifyDetailsOnLogout(ISelenium browser) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; IJavaScriptExecutor js = (IJavaScriptExecutor)driver; Assert.IsFalse(browser.IsVisible(LoginLogoutControls.sidebar), "Sidebar failed to close on Logout"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.LadbrokesHomeLink), "Header(Ladbrokes Logo) is not displayed on Home page after Logout"); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.balance), "Balance is displayed after Logout"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.carousel), "Carousel is not found on Home page on logout"); //Assert.IsTrue(browser.IsVisible(LoginLogoutControls.promotionalBanner), "Promotional banner is not displayed on Home page"); LFcommonObj.selectMenuButton(browser); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.loginOrRegisterLink), "Login/Register element is not present after Logout"); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.logoutLink), "Logout link is present after Logout"); //browser.Click(LoginLogoutControls.menuIcon); js.ExecuteScript("document.getElementById('menu-button').click()"); LFframeworkCommonObj.PageSync(browser); Console.WriteLine("Verification of UI object on Logout was successful"); } catch (Exception ex) { Console.WriteLine("Function 'VerifyDetailsOnLogout' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method verifies the all details, links once the user has logged in /// <example>VerifyDetailsOnLogin(browser)</example> public void VerifyDetailsOnLogin(ISelenium browser) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; //Check elements on Login Assert.IsTrue(browser.IsVisible(LoginLogoutControls.balance), "Balance is not displayed on Login"); LFcommonObj.selectMenuButton(browser); IWebElement username = driver.FindElement(By.XPath("//div[@id='sidebar-user-name' and contains(string(), '" + FrameGlobals.UserDisplayName + "')]")); Assert.IsTrue(username.Displayed, "User name '" + FrameGlobals.UserDisplayName + "' is not diplayed on Login"); Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.logoutLink), "Logout link is not present in the sidebar on Login"); //Verify the links under account LFcommonObj.clickObject(browser, LoginLogoutControls.accountLink); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.deposit), "Deposit link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.withdraw), "Withdraw link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.histroy), "Histroy link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.viewBalances), "View Balances link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.Transfer), "Transfer link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.redeemFreeBets), "Redeem Free Bets link is not present in the Account section"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.depositLimits), "Deposit Limits link is not present in the Account section"); LFcommonObj.clickObject(browser, LoginLogoutControls.accountLink); //Verify links on Sidebar Assert.IsTrue(browser.IsVisible(LoginLogoutControls.moreFromLadbrokes), "More from Ladbrokes link is not present in the sidebar"); LFcommonObj.clickObject(browser, LoginLogoutControls.homeLinkOnSideBar); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.balance), "Failed to navigate to 'Home Page' on tapping the Home icon in the sidebar"); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.sidebar), "Side bar remians on navigating on the home page"); Console.WriteLine("Verification of UI object on Login was successful"); } catch (Exception ex) { Console.WriteLine("Function 'VerifyDetailsOnLogin' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method logs the user out of the application /// <example>Logout(browser)</example> public void Logout(ISelenium browser) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; LFcommonObj.selectMenuButton(browser); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.loginOrRegisterLink), "User is not logged in"); //LFcommonObj.clickObject(browser, LoginLogoutControls.logoutLink, "xpath"); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("logoutObj=document.getElementsByClassName('bxc sidebar-icon logout ml20');logoutObj.item(0).click()"); //js.ExecuteScript("anf = document.getElementById('sidebar-scroll');divName = anf.childNodes[1];ulList = divName.childNodes[9].childNodes;bb = ulList[17].childNodes;bb.item(1).click()"); //Actions builder = new Actions(driver); //IWebElement helpWebElement = driver.FindElement(By.XPath(LoginLogoutControls.logoutLink)); //builder.MoveToElement(helpWebElement).Build().Perform(); LFcommonObj.WaitForLoadingIcon(browser, FrameGlobals.ElementLoadTimeout); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.balance), "Balance is displayed after Logout"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.LadbrokesHomeLink), "Home page is not displayed on logout"); Assert.IsTrue(browser.IsVisible(LoginLogoutControls.carousel), "Carousel is not found on Home page on logout"); Console.WriteLine("Logout was successful"); } catch (Exception ex) { Console.WriteLine("Function 'Logout' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method verifies the all the policies on Home page /// <example>VerifyPolicies(MyBrowser)</example> public void VerifyPolicies(ISelenium browser, string[] Policies, string[] URLs) { try { string url, xPath; for (int i = 0; i < Policies.Length; i++) { HGframeworkCommonObj.PageSync(browser); xPath = "//a[starts-with(@class, 'bxc tac sec-button small footer') and contains(text(), '" + Policies[i] + "')]"; Assert.IsTrue(browser.IsElementPresent(xPath), Policies[i] + " button not found"); browser.Click(xPath); HGframeworkCommonObj.PageSync(browser); HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000"); Thread.Sleep(1000); Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link"); Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container"); Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container"); browser.Click(LoginLogoutControls.CloseButtonInAlertContainer); HGframeworkCommonObj.PageSync(browser); Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button"); browser.Click(xPath); HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000"); Thread.Sleep(1000); Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link"); browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer); HGframeworkCommonObj.PageSync(browser); Thread.Sleep(2000); //Title is different for Desktop policy if (Policies[i] == "Desktop") { HGFcommonObj.SwitchWindow(browser, "Ladbrokes Mobile"); } else { HGFcommonObj.SwitchWindow(browser, "LBR Customer KB"); } url = browser.GetLocation(); // url = driver.Url; browser.Close(); browser.SelectWindow("null"); Thread.Sleep(1000); if (url.ToLower().Trim() == URLs[i].ToLower().Trim()) { Console.WriteLine("'" + Policies[i] + "' validated successfully"); } else { Console.WriteLine("Failed to validate the '" + Policies[i] + "'"); Fail("Mismatch in Actual and Expected URLs"); } } } catch (Exception ex) { Console.WriteLine("Function 'VerifyPolicies' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method registers a new customer /// <example>RegisterCustomer(browser) </example> public string RegisterCustomer(ISelenium browser, string promocode, string country, string accountCurrency, string DOByear) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; TimeSpan ts = new TimeSpan(0, 0, 5); driver.Manage().Timeouts().ImplicitlyWait(ts); Random rnd = new Random(); int rndNumber = rnd.Next(10000); string regMsg, xPath; string[] fName = new string[] { "Dylan", "Ethan", "George", "Hary", "Jacob", "John" }; string[] lName = new string[] { "Brown", "Jones", "Miller", "Roberts", "Taylor", "Wilson" }; string firstname = "Auto" + fName[rnd.Next(0, 5)]; string lastname = "Auto" + lName[rnd.Next(0, 5)]; string username = "******" + rndNumber; EnterRegisterDetails(browser, promocode, country, accountCurrency, DOByear, firstname, lastname, username); //Validate registration clickObject_MobileLobby(browser, MobileLobbyControls.registerNow); // for banned country if (country.ToLower() == "united states") { Assert.IsTrue(browser.IsVisible(MobileLobbyControls.failureRgMsg), "Registration failure message was not displayed"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration page title was not found in the header on registration status"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.Logo), "Ladbrokes Logo was not displayed on registration status"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.backbutton), "Back button was not displayed on registration status"); regMsg = "We are sorry but your country of residence is currently prohibited from using the Ladbrokes service."; xPath = "//ul[@class='error_align']/li[contains(text()[2], '" + regMsg + "')]"; Assert.IsTrue(browser.IsElementPresent(xPath), "Registration failure message was not displayed to the user"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.contactMessage), "Customer contact message was not displayed on failing to create a customer from banned country"); Console.WriteLine("Customer was not registered from a banned country"); } // for below 18 years customers else if ((DateTime.Now.Year - int.Parse(DOByear)) < 18) { Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration Page is not displayed"); xPath = "//div[@class='monthformError parentFormundefined formError']/div[@class='formErrorContent' and contains(text(), 'You are under 18')]"; Assert.IsTrue(browser.IsElementPresent(xPath), "'You are under 18' error message was not displayed"); Console.WriteLine("Error message validated successfully for Customer of age below 18 attaempting to register"); } // for regular customers else { string balanceCurrXpath; if (country.ToLower() == "united kingdom") { balanceCurrXpath = "//div[@class='samount' and contains(text(), 'Balance: £')]/span[@id='headerBalance' and contains(text(), '0.0')]"; regMsg = "Thanks " + firstname + ", your account has now been set up. Your customer ID is " + username + ". You have been sent an email with your details. To get going simply deposit a minimum of £ 5.00 and start betting."; } else { balanceCurrXpath = "//div[@class='samount' and contains(text(), 'Balance: $')]/span[@id='headerBalance' and contains(text(), '0.0')]"; regMsg = "Thanks " + firstname + ", your account has now been set up. Your customer ID is " + username + ". You have been sent an email with your details. To get going simply deposit a minimum of $ 5.00 and start betting."; } Assert.IsTrue(browser.IsVisible(MobileLobbyControls.successfulRgMsg), "Successful Registration message was not displayed, failed to register a new customer '" + username + "'"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration page title was not found in the header after registration"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.closebutton), "Done button was not displayed after registartion"); Assert.IsTrue(browser.IsVisible(balanceCurrXpath), "Balance header was not displayed after registartion"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.depositFunds), "Deposit funds button was not found after registartion"); xPath = "//div[@id='mainContent']/p[contains(text(), '" + regMsg + "')]"; Assert.IsTrue(browser.IsElementPresent(xPath), "Registrain messages was not displayed to the user"); Console.WriteLine("Customer '" + username + "' registered successfully"); } return username; } catch (Exception ex) { CaptureScreenshot(browser, "RegisterCustomer"); Console.WriteLine("Function 'RegisterCustomer' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); return null; } }
///<summary> /// This method enters text in field /// <example>EnterField(browser, xPath)</example> public void EnterField(ISelenium browserObj, string strLocator, string text) { try { Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); browserObj.Focus(strLocator); browserObj.Type(strLocator, ""); browserObj.Type(strLocator, text); CFframeworkCommonObj.PageSync(browserObj); } catch (Exception ex) { Console.WriteLine("Function 'EnterField' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method creates a customer with the same details of a self exclusion customer /// <example>RegisterCustomer_selfExclusion(portalbrowser, adminbrowser) </example> public void RegisterCustomer_selfExclusion(ISelenium browser, ISelenium adminBrowser) { try { string regMsg, gender, xPath; var admincommonObj = new AdminSuite.Common(); Random rnd = new Random(); int rndNumber = rnd.Next(10000); //get details of customer in OB adminBrowser.WindowFocus(); string username = "******" + rndNumber; admincommonObj.SelectMainFrame(adminBrowser); string firstname = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'First Name:')]/following-sibling::td"); string lastname = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Last Name:')]/following-sibling::td"); string title = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Title:')]/following-sibling::td"); if (title.ToLower() == "mr") { gender = "male"; } else { gender = "female"; } string dob = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Date of Birth:')]/following-sibling::td"); string[] arr = dob.Split('-'); string DOByear = arr[0]; System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo(); string DOBmonth = mfi.GetMonthName(int.Parse(arr[1])).ToString(); string DOBday = arr[2]; string houseno = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Address (1)')]/following-sibling::td"); string postcode = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Postcode:')]/following-sibling::td"); string address1 = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(2)')]/following-sibling::td") + adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(3)')]/following-sibling::td"); string address2 = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(3)')]/following-sibling::td"); string city = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'City:')]/following-sibling::td"); string email = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Email:')]/following-sibling::td"); string teleCode = "+44"; string telnumber = "1234567890"; string mobnumber = "1234512345"; string password = "******"; string confirmPassword = "******"; string securityQuestion = "Favourite Colour"; string securityAnswer = "Blue"; string accountCurrency = "UK Pound Sterling"; string country = "United Kingdom"; browser.WindowFocus(); WaitForLoadingIcon_MobileLobby(browser, FrameGlobals.IconLoadTimeout); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration Page is not displayed"); //Enter data in all the fields browser.Type(MobileLobbyControls.promocode, ""); browser.Select(MobileLobbyControls.title, title); browser.Type(MobileLobbyControls.firstname, firstname); browser.Type(MobileLobbyControls.lastname, lastname); //gender if (gender.ToLower().Trim() == "male") { browser.Click(MobileLobbyControls.genderMale); } else { browser.Click(MobileLobbyControls.genderFemale); } browser.Select(MobileLobbyControls.DOBday, DOBday); browser.Select(MobileLobbyControls.DOBmonth, DOBmonth); browser.Select(MobileLobbyControls.DOByear, DOByear); browser.Select(MobileLobbyControls.country, country); browser.Type(MobileLobbyControls.housename, houseno); browser.Type(MobileLobbyControls.postcode, postcode); browser.Type(MobileLobbyControls.address1, address1); browser.Type(MobileLobbyControls.address2, address2); browser.Type(MobileLobbyControls.city, city); browser.Type(MobileLobbyControls.email, email); browser.Type(MobileLobbyControls.telintcode, teleCode); browser.Type(MobileLobbyControls.telnumber, telnumber); browser.Type(MobileLobbyControls.mobintcode, teleCode); browser.Type(MobileLobbyControls.mobnumber, mobnumber); browser.Select(MobileLobbyControls.accountCurrency, accountCurrency); browser.Type(MobileLobbyControls.username, username); browser.Type(MobileLobbyControls.password, password); browser.Type(MobileLobbyControls.confirmPassword, confirmPassword); browser.Select(MobileLobbyControls.securityQuestion, securityQuestion); browser.Type(MobileLobbyControls.securityAnswer, securityAnswer); MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.contactMe, "on"); MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.aggreement, "on"); Thread.Sleep(1000); //Validate registration clickObject_MobileLobby(browser, MobileLobbyControls.registerNow); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration page title was not found in the header after registration"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.failureRgMsg), "Registration failure message was not displayed"); regMsg = "We are sorry but your country of residence is currently prohibited from using the Ladbrokes service."; xPath = "//ul[@class='error_align']/li[contains(text()[2], '" + regMsg + "')]"; Assert.IsTrue(browser.IsElementPresent(xPath), "Registration failure message was not displayed to the user"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.contactMessage), "Customer contact message was not displayed on failing to create a customer from banned country"); Console.WriteLine("Customer was not registered as his details provided matched a self excluded customer"); } catch (Exception ex) { CaptureScreenshot(browser, "EnterRegisterDetails"); Console.WriteLine("Function 'EnterRegisterDetails' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method navigates to the home page /// <example>NavigateToHomePage(browser, SideMenu/Header) </example> public void NavigateToHomePage(ISelenium browserObj, string location) { try { if (location.ToLower().Contains("side")) { selectMenuButton(browserObj); clickObject(browserObj, LoginLogoutControls.homeLinkOnSideBar); } else { if (browserObj.IsVisible(LoginLogoutControls.LadbrokesHomeLink)) { clickObject(browserObj, LoginLogoutControls.LadbrokesHomeLink); Assert.IsTrue(browserObj.IsElementPresent(LoginLogoutControls.carousel), "Failed to navigate to Home page from Ladbrokes Home link"); } } } catch (Exception ex) { Console.WriteLine("Function 'NavigateToHomePage' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
//This method verifies the UI on deposit page public void VerifyDepositPage(ISelenium browser) { try { clickObject_MobileLobby(browser, MobileLobbyControls.depositFunds); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.depositTitle), "Deposit page not found"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.closebutton), "Done button was not displayed after registartion"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.balanceHeader), "Balance header was not displayed after registartion"); // verify UI of deposit page Assert.IsTrue(browser.IsVisible(MobileLobbyControls.cardTypeImages), "Card images was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.cardHolderName), "Card holder's name field was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.cardNo), "Card number field was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.expiryMonth), "Card expiry month listbox was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.cvvNo), "Card expiry year listbox was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.cardPassword), "Card password field was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.amout1), "Amount field was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.amout2), "pens field was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.depositText), "Deposit static text was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.currencySymbol), "Currency symbol was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.dailyLimit), "Daily deposit limit radio was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.weeklyLimit), "Weekly deposit limit radio was not displayed in the deposit page"); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.depositLimitAmount), "Deposit amout listbox was not displayed in the deposit page"); Console.WriteLine("UI of Deposit page was verified successfully"); } catch (Exception ex) { Console.WriteLine("Function 'VerifyDepositPage' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method check/unchecks the check box /// <example>SelectCheckbox(browser, xPath, On/Off)</example> public void SelectCheckbox(ISelenium browserObj, string strLocator, string value) { try { Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); if (value.ToLower().Trim() == "on") { if (!browserObj.IsChecked(strLocator)) { browserObj.Check(strLocator); CFframeworkCommonObj.PageSync(browserObj); if (!(browserObj.IsChecked(strLocator))) { Console.WriteLine("Failed to check the checkbox - " + strLocator); Fail("Failed to check the checkbox - " + strLocator); } } } else { browserObj.Uncheck(strLocator); CFframeworkCommonObj.PageSync(browserObj); if (browserObj.IsChecked(strLocator)) { Console.WriteLine("Failed to Uncheck the checkbox - " + strLocator); Fail("Failed to check the Uncheckbox - " + strLocator); } } } catch (Exception ex) { Console.WriteLine("Function 'SelectCheckbox' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
///<summary> /// This method enters all details of a customer /// <example>EnterRegisterDetails(browser) </example> public string EnterRegisterDetails(ISelenium browser, string promocode, string country, string accountCurrency, string DOByear, string firstname, string lastname, string username) { try { IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; Random rnd = new Random(); int rndNumber = rnd.Next(10000); string[] pCode = new string[] { "HA2 9SR", "HA2 9SG", "HA2 9SE", "HA2 9SN", "HA2 9SW", "HA2 9SX", "HA2 8SS", "HA2 8SE", "HA2 8SX", "HA2 8SN", "HA2 8SA" }; string title = "Mr"; string gender = "male"; string DOBmonth = "January"; string DOBday = rnd.Next(20, 30).ToString(); string houseno = rndNumber.ToString(); string postcode = pCode[rnd.Next(0, 10)];; string address1 = "Ladbrokes Ltd, Imperial Drive"; string address2 = "Harrow"; string city = "Middx"; string email = firstname + lastname + "@gmail.com"; string teleCode = "+44"; string telnumber = "1234567890"; string mobnumber = "1234512345"; string password = "******"; string confirmPassword = "******"; string securityQuestion = "Favourite Colour"; string securityAnswer = "Blue"; WaitForLoadingIcon_MobileLobby(browser, FrameGlobals.IconLoadTimeout); Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration Page is not displayed"); //Enter data in all the fields browser.Type(MobileLobbyControls.promocode, promocode); browser.Select(MobileLobbyControls.title, title); browser.Type(MobileLobbyControls.firstname, firstname); browser.Type(MobileLobbyControls.lastname, lastname); //gender if (gender.ToLower().Trim() == "male") { browser.Click(MobileLobbyControls.genderMale); } else { browser.Click(MobileLobbyControls.genderFemale); } browser.Select(MobileLobbyControls.DOBday, DOBday); browser.Select(MobileLobbyControls.DOBmonth, DOBmonth); browser.Select(MobileLobbyControls.DOByear, DOByear); if ((DateTime.Now.Year - int.Parse(DOByear)) < 18) { Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration Page is not displayed"); string xPath = "//div[@class='monthformError parentFormundefined formError']/div[@class='formErrorContent' and contains(text(), 'You are under 18')]"; Assert.IsTrue(browser.IsElementPresent(xPath), "'You are under 18' error message was not displayed"); } browser.Select(MobileLobbyControls.country, country); browser.Type(MobileLobbyControls.housename, houseno); browser.Type(MobileLobbyControls.postcode, postcode); if (country.ToLower() == "united kingdom") { clickObject_MobileLobby(browser, MobileLobbyControls.findaddress); } browser.Type(MobileLobbyControls.address1, address1); browser.Type(MobileLobbyControls.address2, address2); browser.Type(MobileLobbyControls.city, city); browser.Type(MobileLobbyControls.email, email); browser.Type(MobileLobbyControls.telintcode, teleCode); browser.Type(MobileLobbyControls.telnumber, telnumber); browser.Type(MobileLobbyControls.mobintcode, teleCode); browser.Type(MobileLobbyControls.mobnumber, mobnumber); browser.Select(MobileLobbyControls.accountCurrency, accountCurrency); browser.Type(MobileLobbyControls.username, username); browser.Type(MobileLobbyControls.password, password); browser.Type(MobileLobbyControls.confirmPassword, confirmPassword); browser.Select(MobileLobbyControls.securityQuestion, securityQuestion); browser.Type(MobileLobbyControls.securityAnswer, securityAnswer); MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.contactMe, "on"); MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.aggreement, "on"); Thread.Sleep(1000); return username; } catch (Exception ex) { CaptureScreenshot(browser, "EnterRegisterDetails"); Console.WriteLine("Function 'EnterRegisterDetails' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); return null; } }
/// <summary> /// Method to update and validate SelectionPrice Update validation /// </summary> public void SelectionPriceUpdateValidation(ISelenium browser, ISelenium adminBrowser, TestData testData, string navPanel, string odds,string eventName) { string selectionId = string.Empty; try { btCommonObj.AddAndVerifySelectionInBetslip_HR(browser, testData.ClassName, navPanel, testData.ClassName, testData.TypeName, testData.SubTypeName, testData.EventName, testData.MarketName, testData.SelectionName, testData.Odds, false, false); selectionId = testRepositoryCommonObj.GetSelectionIDFromBetslip(browser, testData.SelectionName, testData.EventName); adminCommonObj.UpdateSelection(adminBrowser, selectionId, odds, "Active", ""); Thread.Sleep(FrameGlobals.OpenBetReflectTimeOut); Console.WriteLine("Selection price is updated in admin"); btCommonObj.NavigateToEventDetailsPage_HR(browser, testData.ClassName, navPanel, testData.ClassName, testData.TypeName, testData.SubTypeName, eventName, testData.MarketName); Assert.IsTrue(browser.IsVisible("//div[@class='bxcl bg2 mb4' and contains(string(),'" + testData.SelectionName + "') and contains(string(),'" + odds + "')]"), "Selection price is not displayed in the event details page"); Console.WriteLine("" + odds + " selection price is updated on the Racecard accessed via Today tab under HR hompage"); } catch (Exception ex) { Console.WriteLine(ex.Message); CaptureScreenshot(browser, "SelectionPriceUpdateValidation"); } finally { adminCommonObj.UpdateSelection(adminBrowser, selectionId, odds, "Active", ""); } }