[Fact] //Admin_30 public void VerifyLedgerEntryDebit() { try { string accountId; string toastMessage; string product; bool creditFlag; string amount; string negativeAmount; string comment; string productBalancesBeforeUpdate; string productBalancesAfterUpdate; product = TestData.GetData("TCAdmin30_Product"); amount = TestData.GetData("TCAdmin30_Amount"); negativeAmount = TestData.GetData("TCAdmin30_NegativeAmount"); comment = TestData.GetData("TCAdmin30_Comment"); accountId = TestData.GetData("TCAdmin30_AccountID"); 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); // Set creditFlag to False in case of debit amount creditFlag = false; // 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)); // Submit Submit Ledger Entry with negative value adminAccountPage.SubmitLedgerEntryWithNegativeValue(product, creditFlag, negativeAmount, comment); // Verify submit ledger invalid request message toastMessage = adminAccountPage.SubmitLedgerInvalidToastMessage(); Assert.Equal(Const.LedgerEntryInvalidRequestMsg, toastMessage); // Fetch the USD Account balance before update productBalancesBeforeUpdate = adminAccountPage.ProductAmountBalancesBeforeUpdate(); // Submit Submit Ledger Entry adminAccountPage.SubmitLedgerEntry(product, creditFlag, amount, comment); // Verify submit ledger success msg toastMessage = adminAccountPage.SubmitLedgerToastMessage(); Assert.Equal(Const.LedgerEntrySuccessMsg, toastMessage); TestProgressLogger.LogCheckPoint(LogMessage.VerifyToastMSG); adminAccountPage.ClickOnRefreshInUserAccountSection(driver); // Fetch the USD Account balance after update productBalancesAfterUpdate = adminAccountPage.ProductAmountBalancesAfterUpdate(); // Verify that the balances are incremented by amount value Assert.True(adminAccountPage.VerifyUpdatedDebitBalance(amount, productBalancesBeforeUpdate, productBalancesAfterUpdate)); // Logout from admin. admincommonfunctions.UserMenuBtn(); adminfunctions.AdminLogOut(); } catch (NoSuchElementException ex) { TestProgressLogger.TakeScreenshot(); TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace); TestProgressLogger.LogError(LogMessage.VerifyLedgerEntryDebitTestFailed, ex); throw; } catch (Exception e) { TestProgressLogger.TakeScreenshot(); TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace); TestProgressLogger.LogError(LogMessage.VerifyLedgerEntryDebitTestFailed, e); throw e; } finally { TestProgressLogger.EndTest(); } }