[Fact]      //Admin_22
        public void ExportAllAccountsBalancesCSVFile()
        {
            try
            {
                string allBalancesFileName;
                string toastMessage;

                allBalancesFileName = TestData.GetData("TCAdmin22_AccountsBalancesFileName");

                AdminFunctions       adminfunctions       = new AdminFunctions(TestProgressLogger);
                AdminCommonFunctions admincommonfunctions = new AdminCommonFunctions(TestProgressLogger);
                AdminAccountsPage    adminAccountPage     = new AdminAccountsPage(TestProgressLogger);
                GenericUtils         genericUtils         = new GenericUtils(TestProgressLogger);

                // login in admin
                adminfunctions.AdminLogIn(TestProgressLogger, Const.ADMIN1);

                // Navigate on Accounts page.
                admincommonfunctions.SelectAccountsMenu();
                admincommonfunctions.SelectAccountsBalancesTab();
                TestProgressLogger.LogCheckPoint(LogMessage.NavigateAccountPage);

                // Delete all previous file and download allaccounts csv file.
                genericUtils.DeleteAllFiles();
                toastMessage = adminAccountPage.ClickOnExportAllBalancesButton();
                TestProgressLogger.LogCheckPoint(LogMessage.DownloadAllBalancessCSVFile);

                // Verify success toast msg.
                Assert.Equal(toastMessage, Const.TCAdmin22_AllAccountBalancesDownloadSuccessfullyMSG);

                // Verify data in all balances csv file.
                Assert.True(adminAccountPage.VerifyAllBalancesCSVData(allBalancesFileName));
                TestProgressLogger.LogCheckPoint(LogMessage.VerifyAllBalancesCSVFile);

                // Logout from admin.
                admincommonfunctions.UserMenuBtn();
                adminfunctions.AdminLogOut();
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(LogMessage.ExportAllBalancesCSVFileTestFailed, ex);
                throw;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(LogMessage.ExportAllBalancesCSVFileTestFailed, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
Example #2
0
        public void TCAdmin28_VerifyExportedByPermissionsDataTest()
        {
            selectByPermissionOption = TestData.GetData("TCAdmin28_SelectByPermissionOption");
            selectUserPermission     = TestData.GetData("TCAdmin28_SelectUserPermission");
            byPermissionUserIdValue  = TestData.GetData("TCAdmin28_UserId");

            AdminFunctions       objAdminFunctions       = new AdminFunctions(TestProgressLogger);
            AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(TestProgressLogger);
            AdminUsersPage       objAdminUsersPage       = new AdminUsersPage(TestProgressLogger);
            GenericUtils         genericUtils            = new GenericUtils(TestProgressLogger);

            try
            {
                TestProgressLogger.StartTest();

                // This method is used to Delete all files from the Folder
                genericUtils.DeleteAllFiles();
                // Login as admin -> Click on "Users" menu button -> Users Tab
                objAdminUsersPage.SelectAdminUserTab();
                // Verify the "All users" exported csv file in the Admin UI
                Assert.True(objAdminUsersPage.VerifyExportByPermission(selectByPermissionOption, byPermissionUserIdValue, selectUserPermission));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifyByPermissionExportedCSVFileFailed), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifyByPermissionExportedCSVFileFailed), e);
                throw e;
            }
            finally
            {
                objAdminCommonFunctions.UserMenuBtn();
                objAdminFunctions.AdminLogOut();
                TestProgressLogger.EndTest();
            }
        }
        [Fact]      //Admin_9
        public void VerifyReportsDownloadedExportToCSV()
        {
            try
            {
                string accountId;
                string instrument;
                string buyTab;
                string buyOrderSize;
                string limitPrice;
                string timeInForce;
                string quantity;
                string price;
                string orderID;
                string openOrderFileName;
                string accountActivityFileName;
                string orderHistoryFileName;
                bool   accountActivityVal;

                instrument              = TestData.GetData("Instrument");
                limitPrice              = TestData.GetData("TCAdmin8_LimitPrice");
                timeInForce             = TestData.GetData("TimeInForce");
                buyTab                  = TestData.GetData("BuyTab");
                buyOrderSize            = TestData.GetData("TCAdmin8_BuyOrderSize");
                accountId               = TestData.GetData("TCAdmin4_UserAccountID");
                quantity                = TestData.GetData("TCAdmin8_QunatityField");
                price                   = TestData.GetData("TCAdmin8_PriceField");
                openOrderFileName       = TestData.GetData("TCAdmin9_OpenOrderFileName");
                accountActivityFileName = TestData.GetData("TCAdmin9_AccountActivityFileName");
                orderHistoryFileName    = TestData.GetData("TCAdmin9_AccountOrderHistoryFileName");

                AdminFunctions       adminfunctions       = new AdminFunctions(TestProgressLogger);
                AdminCommonFunctions admincommonfunctions = new AdminCommonFunctions(TestProgressLogger);
                AdminAccountsPage    adminAccountPage     = new AdminAccountsPage(TestProgressLogger);
                UserFunctions        userFunctions        = new UserFunctions(TestProgressLogger);
                UserCommonFunctions  userCommonFunction   = new UserCommonFunctions(TestProgressLogger);
                GenericUtils         genericUtils         = new GenericUtils(TestProgressLogger);

                // Place sell order to set up market
                userFunctions.LogIn(TestProgressLogger, Const.USER17);
                userCommonFunction.CancelAndPlaceLimitBuyOrder(driver, instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                TestProgressLogger.LogCheckPoint(LogMessage.PlaceBuyOrder);

                // login in admin
                adminfunctions.AdminLogIn(TestProgressLogger, Const.ADMIN1);

                // Navigate on Accounts page.
                admincommonfunctions.SelectAccountsMenu();
                admincommonfunctions.SelectAccountsTab();
                TestProgressLogger.LogCheckPoint(LogMessage.NavigateAccountPage);

                // Click on ViewAll and search by accountid and double click.
                adminAccountPage.ClickOnViewAll(driver);
                adminAccountPage.SearchByAccountID(driver, accountId);
                adminAccountPage.DoubleClickOnAccountName(driver, accountId);
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.NavigateAccountPage, accountId));

                // Click on showall link under open order section.
                adminAccountPage.ClickShowAllUnderOpenOrderSection(driver);
                orderID = adminAccountPage.GetOrderIDInAccountOrderPage(driver);

                // Delete All previous file and download openorder csv file and verify data.
                genericUtils.DeleteAllFiles();
                adminAccountPage.ClickExportToCSVOpenOrder(driver);
                Dictionary <string, string> openOrderData = adminAccountPage.GetOpenOrderCSVData(orderID, openOrderFileName);
                Assert.Equal(limitPrice, openOrderData.GetValueOrDefault(price));
                Assert.Equal(buyOrderSize, openOrderData.GetValueOrDefault(quantity));
                TestProgressLogger.LogCheckPoint(LogMessage.VerifyDownloadCSVFileOfOpenOrder);

                // Click on showall link under account activity section.
                adminAccountPage.SelectAccountLink(driver);
                adminAccountPage.ClickShowAllUnderAccountActivitySection(driver);

                // Delete All previous file and download transactionhistory csv file and verify data.
                genericUtils.DeleteAllFiles();
                adminAccountPage.ClickExportToCSVAccountActivity(driver);
                accountActivityVal = adminAccountPage.VerifyAccountActivityCSVData(accountActivityFileName, orderID);
                Assert.True(accountActivityVal);
                TestProgressLogger.LogCheckPoint(LogMessage.VerifyDownloadCSVFileOfAccountActivity);

                // Click on showall link under order history section.
                adminAccountPage.SelectAccountLink(driver);
                adminAccountPage.ClickOnUserAccountTab(driver);
                adminAccountPage.ClickShowAllUnderOrderHistorySection(driver);

                // Delete All previous file and download order history csv file and verify data.
                genericUtils.DeleteAllFiles();
                adminAccountPage.ClickExportToCSVOrderHistory(driver);
                accountActivityVal = adminAccountPage.VerifyAccountActivityCSVData(orderHistoryFileName, orderID);
                Assert.True(accountActivityVal);
                TestProgressLogger.LogCheckPoint(LogMessage.VerifyDownloadCSVFileOfOrderHistory);

                // Click on showall link under order history section.
                adminAccountPage.SelectAccountLink(driver);
                adminAccountPage.ClickOnUserAccountTab(driver);
                adminAccountPage.ClickShowAllUnderTradeSection(driver);

                // Delete All previous file and download trade csv file
                genericUtils.DeleteAllFiles();
                adminAccountPage.ClickExportToCSVTrade(driver);

                TestProgressLogger.LogCheckPoint(LogMessage.VerifyDownloadCSVFileOfTrade);


                // Logout from admin.
                admincommonfunctions.UserMenuBtn();
                adminfunctions.AdminLogOut();
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(LogMessage.VerifyReportsDownloadedExportToCSVTestFailed, ex);
                throw;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(LogMessage.VerifyReportsDownloadedExportToCSVTestFailed, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
        public void DownloadFileTest()
        {
            AdminFunctions       objAdminFunctions       = new AdminFunctions(TestProgressLogger);
            AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(TestProgressLogger);
            AdminUsersPage       objAdminUsersPage       = new AdminUsersPage(TestProgressLogger);
            UserFunctions        userFunctions           = new UserFunctions(TestProgressLogger);
            GenericUtils         genericUtils            = new GenericUtils(TestProgressLogger);

            try
            {
                List <KeyValuePair <string, string> > superUsersData;
                string superUsersList = "";
                string date;
                TestProgressLogger.StartTest();

                //Login as admin -> Click on "Users" menu button
                genericUtils.DeleteAllFiles();
                objAdminFunctions.AdminLogIn(TestProgressLogger);
                objAdminCommonFunctions.ClickOnUsersMenuLink();
                objAdminCommonFunctions.UsersTabBtn();
                objAdminCommonFunctions.ClickOnExportButton();
                Thread.Sleep(2000);
                objAdminCommonFunctions.ExportSuperUsers();
                Thread.Sleep(3000);
                date = GenericUtils.GetCurrentTimeWithHyphen();
                var path = Directory.GetCurrentDirectory() + "\\DataTest\\Superusers (" + date + ").csv";
                superUsersData = genericUtils.ReadDataFromCSV(@path);
                for (int i = 0; i < superUsersData.Count; i++)
                {
                    if (superUsersData[i].Key == "UserId")
                    {
                        if (superUsersData[i].Value == "123")
                        {
                            for (int j = i; j < i + 12; j++)
                            {
                                superUsersList = superUsersList + " || " + superUsersData[j].Key + ":" + superUsersData[j].Value;
                            }
                            TestProgressLogger.LogCheckPoint(superUsersList);
                            break;
                        }
                    }
                }
                TestProgressLogger.LogCheckPoint("Passed");
            }

            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifyAddUserPassed), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifyAddUserFailed), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }