//This method will login to admin portal
        public void AdminLogIn(ProgressLogger logger, string userName = Const.ADMIN1)
        {
            try
            {
                username = data.AdminPortal.Users[userName].UserName;
                password = data.AdminPortal.Users[userName].Password;
                string userUrl        = data.AdminPortal.PortalUrl;
                string userServerName = data.AdminPortal.PortalServerUrl;

                driver.Navigate().GoToUrl(userUrl);
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
                driver.Manage().Window.Size = new Size(1366, 768);

                UserSetFunctions.EnterText(AdminUserName(), username);
                UserSetFunctions.EnterText(AdminUserPassword(), password);
                UserSetFunctions.Click(AdminSignIn());
                Assert.Equal(driver.Title.ToLower(), Const.AdminLoginTitle.ToLower());
                logger.LogCheckPoint(String.Format(LogMessage.AdminLoginSuccessfullMsg, userName));
                Thread.Sleep(2000);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        // This method is used to login using the credentials captured from UI after assigning the account
        public bool LogInUsingCredsAfterAssignAccount(ProgressLogger logger, string userName, string userPassword)
        {
            bool flag = false;

            try
            {
                UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginName, 15), userName);
                UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginPassword, 15), userPassword);
                UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, userLoginButton, 15));
                if (driver.Title.ToLower().Equals(apexWebTitle.ToLower()))
                {
                    flag = true;
                }

                if (flag)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.VerifyLoginAfterAssignAccountPassed, userName));
                    Thread.Sleep(2000);
                    LogOut();
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.VerifyLoginAfterAssignAccountFailed, userName));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
        //This method is used for User Login
        public void LogIn(ILog logger = null)
        {
            try
            {
                username = data.UserPortal.Users["User1"].UserName;
                password = data.UserPortal.Users["User1"].Password;
                string userUrl        = data.UserPortal.PortalUrl;
                string userServerName = data.UserPortal.PortalServerUrl;

                driver.Navigate().GoToUrl(userUrl);
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
                driver.Manage().Window.Size = new Size(1366, 768);
                IWebElement serverWebElement = driver.FindElement(selectServer);

                UserSetFunctions.SelectDropdown(serverWebElement, userServerName);
                UserSetFunctions.EnterText(driver.FindElement(userLoginName), username);
                UserSetFunctions.EnterText(driver.FindElement(userLoginPassword), password);
                UserSetFunctions.Click(driver.FindElement(userLoginButton));
                Assert.Equal(driver.Title.ToLower(), "APEX Web".ToLower());
                // logger.Info("User "+ username +" logged in successfully");
            }
            catch (Exception e)
            {
                logger.Error("Login failed");
                logger.Error(e.StackTrace);
                throw e;
            }
        }
Esempio n. 4
0
 private string UserLogin(ProgressLogger logger, string userName, string userServerName, bool changeServerOnly = false)
 {
     try
     {
         string defaultSelectedServer;
         username = data.UserPortal.Users[userName].UserName;
         password = data.UserPortal.Users[userName].Password;
         IWebElement   serverWebElement = driver.FindElement(selectServer);
         SelectElement selectObj        = new SelectElement(serverWebElement);
         defaultSelectedServer = selectObj.SelectedOption.Text;
         Thread.Sleep(1000);
         if (!(userServerName.Equals(defaultSelectedServer)))
         {
             UserSetFunctions.SelectDropdown(serverWebElement, userServerName);
         }
         Thread.Sleep(1000);
         if (changeServerOnly)
         {
             return(null);
         }
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginName, 15), username);
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginPassword, 15), password);
         UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, userLoginButton, 15));
         Assert.Equal(driver.Title.ToLower(), apexWebTitle.ToLower());
         logger.LogCheckPoint(string.Format(LogMessage.UserLoggedInSuccessfully, username));
         Thread.Sleep(2000);
         return(username);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 5
0
        // This method is used to login using the credentials captured from UI after unassigning the account
        public bool LogInUsingCredsAfterUnassignAccount(ProgressLogger logger, string userName, string userPassword)
        {
            bool flag = false;

            try
            {
                UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginName, 15), userName);
                UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, userLoginPassword, 15), userPassword);
                UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, userLoginButton, 15));

                //When trying to login using credential after unassigining the account then page is showing blank
                //So in case we have used below condition to check login.
                //Once login failed error messges shows then use below comment code in if condition
                //LoginErrorMsg().Text.Equals(Const.LoginErrroMsg)
                if (driver.Title.ToLower().Equals(apexWebTitle.ToLower()))
                {
                    flag = true;
                }

                if (flag)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.VerifyLoginAfterUnassignAccountPassed, userName));
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.VerifyLoginAfterUnassignAccountFailed, userName));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
 public void CloseAdvancedOrderSection()
 {
     try
     {
         IWebElement closeadvanced = driver.FindElement(CloseIconAdvancedOrder);
         UserSetFunctions.Click(closeadvanced);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 7
0
 public string GetTextOfLoggedInUser()
 {
     try
     {
         UserSetFunctions.Click(driver.FindElement(loggedInUserName));
         return(driver.FindElement(loggedInUserNameText).Text);
     }
     catch (Exception)
     {
         throw;
     }
 }
 //This method will click on Sign Out button
 public void AdminLogOut()
 {
     try
     {
         Thread.Sleep(2000);
         UserSetFunctions.Click(AdminSignout());
         logger.LogCheckPoint(String.Format(LogMessage.AdminLogoutSuccessfullMsg));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 9
0
 public static void AdvanceOrder(ILog logger)
 {
     try
     {
         UserSetFunctions.Click(OrderEntryTab());
         UserSetFunctions.Click(AdvancedOrderLink());
     }
     catch (Exception e)
     {
         logger.Error("Click operation failed on Advance Order link");
         logger.Error(e.StackTrace);
         throw e;
     }
 }
 // This method cancels the Sell order through Order Book
 public static void CancelOrderBookSellOrder(IWebDriver driver)
 {
     try
     {
         IWebElement cancelSellElement = driver.FindElement(cancelSellOrder);
         if (cancelSellElement.Displayed)
         {
             UserSetFunctions.Click(cancelSellElement);
         }
     }
     catch (NoSuchElementException)
     {
     }
 }
 //This method closes the Advanced Order Section
 public static void CloseAdvancedOrderSection(IWebDriver driver, ProgressLogger logger)
 {
     try
     {
         IWebElement closeAdvanced = GenericUtils.WaitForElementVisibility(driver, closeIconAdvancedOrder, 30);
         UserSetFunctions.Click(closeAdvanced);
         Thread.Sleep(2000);
     }
     catch (Exception e)
     {
         logger.Error(LogMessage.CloseAdvanceOrderSectFailureMsg, e);
         logger.Error(e.StackTrace);
         throw;
     }
 }
Esempio n. 12
0
 public static void CloseAdvancedOrderSection(IWebDriver driver, ILog logger)
 {
     try
     {
         IWebElement closeAdvanced = GenericUtils.WaitForElementVisibility(driver, closeIconAdvancedOrder, 30);
         UserSetFunctions.Click(closeAdvanced);
         Thread.Sleep(2000);
     }
     catch (Exception e)
     {
         logger.Error("Close Advanced Order Section Failed");
         logger.Error(e.StackTrace);
         throw e;
     }
 }
Esempio n. 13
0
 public static void SelectExchange(ILog logger)
 {
     try
     {
         UserSetFunctions.Click(ExchangeButton());
         Thread.Sleep(2000);
         string currenturl = driver.Url;
         Assert.Contains("exchange", currenturl);
     }
     catch (Exception e)
     {
         logger.Error("Select Exchange failed");
         logger.Error(e.StackTrace);
         throw e;
     }
 }
 public static void CancelAllOrders(IWebDriver driver)
 {
     try
     {
         ScrollingDownVertical(driver);
         IWebElement cancelElement = driver.FindElement(cancelAllOrder);
         if (cancelElement.Enabled)
         {
             UserSetFunctions.Click(cancelElement);
             Thread.Sleep(4000);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 15
0
        //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 will click on "confirm Order" button
        public static void ConfirmWindowOrder(string askPrice, string limitPrice, IWebDriver driver)
        {
            Thread.Sleep(2000);
            double askPriceInt   = Double.Parse(askPrice);
            double limitPriceInt = Double.Parse(limitPrice);

            try
            {
                if (askPriceInt > limitPriceInt)
                {
                    UserSetFunctions.Click(ConfirmPopUp(driver));
                }
            }
            catch (NoSuchElementException)
            {
            }
        }
 //This method is used for User Logout
 public void LogOut()
 {
     try
     {
         Thread.Sleep(2000);
         UserCommonFunctions.ScrollingUpVertical(driver);
         UserSetFunctions.Click(driver.FindElement(loggedInUserName));
         UserSetFunctions.Click(driver.FindElement(userSignOutButton));
         logger.Info("User " + username + " logged out successfully");
     }
     catch (Exception e)
     {
         logger.Error("Logout failed");
         logger.Error(e.StackTrace);
         throw e;
     }
 }
Esempio n. 18
0
 //This method is used for User Logout
 public void LogOut()
 {
     try
     {
         Thread.Sleep(2000);
         if (!driver.Url.EndsWith(Const.LoginText))
         {
             UserCommonFunctions.ScrollingUpVertical(driver);
             UserSetFunctions.Click(driver.FindElement(loggedInUserName));
             UserSetFunctions.Click(driver.FindElement(userSignOutButton));
             logger.LogCheckPoint(string.Format(LogMessage.UserLoggedOutSuccessfully, username));
         }
         Thread.Sleep(2000);
     }
     catch (Exception e)
     {
         logger.LogError(LogMessage.UserLogoutFailed, e);
         throw;
     }
 }
Esempio n. 19
0
 // 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;
     }
 }