///<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); } }