// This method is used to register a new user public string RegisterNewUser(IWebDriver driver) { try { string randomString; string email; string randomUserName; string userUrl = data.UserPortal.PortalUrl; string userName = TestData.GetData("TC45_UserName"); string emailDomain = Const.EmailDomain; string password = TestData.GetData("TC45_Password"); string retypePassword = TestData.GetData("TC45_Password"); randomString = GenericUtils.RandomString(Const.RandomStringLength); email = randomString + emailDomain; randomUserName = userName + randomString; logger.LogCheckPoint(String.Format(LogMessage.UserSignUpStarted, randomUserName, email)); UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, signUpLink, 15)); UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpUserName, 15), randomUserName); UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpEmail, 15), email); UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpPassword, 15), password); UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpRetypePassword, 15), retypePassword); UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, signUpButton, 15)); GenericUtils.WaitForElementPresence(driver, signUpSuccess, 15); logger.LogCheckPoint(String.Format(LogMessage.UserSignUpSuccess, randomUserName, email)); Thread.Sleep(2000); return(randomUserName); } catch (NoSuchElementException ex) { logger.TakeScreenshot(); logger.LogError(LogMessage.UserSignUpFailure, ex); throw; } catch (Exception e) { logger.TakeScreenshot(); logger.LogError(LogMessage.UserSignUpFailure, e); throw; } }
//This method is used for User Login //If the user is already logged in, then this method logs out user and then logs in public string LogIn(ProgressLogger logger, string userName = Const.USER5, bool changeServerOnly = false) { string username = null; apexWebTitle = TestData.GetData("HomePageTitle"); string userUrl = data.UserPortal.PortalUrl; string userServerName = data.UserPortal.PortalServerUrl; driver.Navigate().GoToUrl(userUrl); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20); driver.Manage().Window.Size = new Size(1366, 768); Thread.Sleep(1000); if (driver.Url.EndsWith(Const.LoginText)) { try { username = UserLogin(logger, userName, userServerName, changeServerOnly); } catch (Exception e) { logger.TakeScreenshot(); logger.Error(Const.UserLoginFailed, e); throw e; } } else { try { driver.Navigate().Refresh(); Thread.Sleep(2000); UserSetFunctions.Click(GenericUtils.WaitForElementVisibility(driver, loggedInUserName, 30)); UserSetFunctions.Click(GenericUtils.WaitForElementVisibility(driver, userSignOutButton, 30)); Thread.Sleep(2000); username = UserLogin(logger, userName, userServerName, changeServerOnly); } catch (Exception e) { logger.Error(Const.UserLogoutFailed, e); throw e; } } return(username); }
// This method verifies affiliates program public bool VerifyAffiliateProgramFunctionality(IWebDriver driver, string verificationLevel) { var flag = false; int initialAffiliates; string registeredUser; string affiliateTagURL; int affiliatesAfterUserRegistration; UserFunctions userFunctions = new UserFunctions(logger); AdminFunctions objAdminFunctions = new AdminFunctions(logger); AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(logger); try { // This method selects the Affiliate Program link from User Settings page SelectAffiliateProgram(); // Get existing number of affilites for the logged in user initialAffiliates = GetnumberOfAffiliates(driver); logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramInitialAffiliates, initialAffiliates)); // Copy the affiliate tag URL and navigate to the URL UserSetFunctions.Click(CopyAffiliateTagButton()); affiliateTagURL = AffiliateTagDesc().Text; logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramURLCopied, affiliateTagURL)); userFunctions.LogOut(); driver.Navigate().GoToUrl(affiliateTagURL); // Change the server URL userFunctions.LogIn(logger, changeServerOnly: true); // Register a new user registeredUser = userFunctions.RegisterNewUser(driver); // Login as Admin and complete KYC of the registered user try { objAdminFunctions.AdminLogIn(logger); logger.LogCheckPoint(String.Format(LogMessage.KYCStarted, registeredUser)); objAdminCommonFunctions.ClickOnUsersMenuLink(); objAdminCommonFunctions.SelectUserFromUserList(driver, registeredUser); // Edit the User Email Verified status to checked objAdminCommonFunctions.EditUserEmailStatus(registeredUser); // Scroll don to User Accounts section and open the user account UserCommonFunctions.ScrollingDownVertical(driver); objAdminCommonFunctions.OpenAccountFromUserPage(); // Edit the Verification Level of the user to 3 objAdminCommonFunctions.EditUserVerificationLevel(verificationLevel); logger.LogCheckPoint(String.Format(LogMessage.KYCSuccess, registeredUser)); objAdminCommonFunctions.UserMenuBtn(); objAdminFunctions.AdminLogOut(); } catch (Exception) { logger.TakeScreenshot(); logger.LogCheckPoint(String.Format(LogMessage.KYCFailure, registeredUser)); throw; } // Login as the user and verify the number of affiliates userFunctions.LogIn(logger, Const.USER12); SelectAffiliateProgram(); affiliatesAfterUserRegistration = GetnumberOfAffiliates(driver); // The number of affiliates should increase by 1 -> Return true if ((affiliatesAfterUserRegistration - initialAffiliates) == 1) { flag = true; logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramFinalAffiliates, affiliatesAfterUserRegistration)); } } catch (NoSuchElementException) { logger.TakeScreenshot(); throw; } catch (Exception) { logger.TakeScreenshot(); throw; } return(flag); }
// This method verifies affiliates program public bool VerifyAffiliateProgramFunctionality(IWebDriver driver, string verificationLevel) { var flag = false; int initialAffiliates; string registeredUser; string affiliateTagURL; UserFunctions userFunctions = new UserFunctions(logger); AdminFunctions objAdminFunctions = new AdminFunctions(logger); AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(logger); try { SelectAffiliateProgram(); initialAffiliates = GetnumberOfAffiliates(driver); logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramInitialAffiliates, initialAffiliates)); UserSetFunctions.Click(CopyAffiliateTagButton()); affiliateTagURL = AffiliateTagDesc().Text; logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramURLCopied, affiliateTagURL)); userFunctions.LogOut(); driver.Navigate().GoToUrl(affiliateTagURL); userFunctions.LogIn(logger, changeServerOnly: true); // Register a new user registeredUser = userFunctions.RegisterNewUser(driver); // Login as Admin and complete KYC of the registered user try { objAdminFunctions.AdminLogIn(logger); logger.LogCheckPoint(String.Format(LogMessage.KYCStarted, registeredUser)); objAdminCommonFunctions.ClickOnUsersMenuLink(); objAdminCommonFunctions.SelectUserFromUserList(driver, registeredUser); objAdminCommonFunctions.EditUserEmailStatus(registeredUser); UserCommonFunctions.ScrollingDownVertical(driver); objAdminCommonFunctions.OpenAccountFromUserPage(); objAdminCommonFunctions.EditUserVerificationLevel(verificationLevel); logger.LogCheckPoint(String.Format(LogMessage.KYCSuccess, registeredUser)); objAdminCommonFunctions.UserMenuBtn(); objAdminFunctions.AdminLogOut(); } catch (Exception e) { logger.TakeScreenshot(); logger.LogCheckPoint(String.Format(LogMessage.KYCFailure, registeredUser)); throw e; } // Login as the user and verify the number of affiliates userFunctions.LogIn(logger, Const.USER12); SelectAffiliateProgram(); int affiliatesAfterUserRegistration = GetnumberOfAffiliates(driver); if ((affiliatesAfterUserRegistration - initialAffiliates) == 1) { flag = true; logger.LogCheckPoint(String.Format(LogMessage.AffiliateProgramFinalAffiliates, affiliatesAfterUserRegistration)); } } catch (NoSuchElementException ex) { logger.TakeScreenshot(); throw ex; } catch (Exception e) { logger.TakeScreenshot(); throw e; } return(flag); }