Ejemplo n.º 1
0
        public void TC3_VerifyBuyMarketOrder()
        {
            try
            {
                instrument           = TestData.GetData("Instrument");
                buyTab               = TestData.GetData("BuyTab");
                sellTab              = TestData.GetData("SellTab");
                marketOrderBuyAmount = TestData.GetData("TC3_MarketOrderBuyAmount");
                feeComponent         = TestData.GetData("FeeComponent");
                sellOrderSize        = TestData.GetData("TC3_SellOrderSize");
                limitPrice           = TestData.GetData("TC3_LimitPrice");
                timeInForce          = TestData.GetData("TC3_TimeInForce");
                string feeValue;
                Dictionary <string, string> placeMarketBuyOrder;

                // Get fee based on buy amount and fee component
                feeValue = GenericUtils.FeeAmount(marketOrderBuyAmount, feeComponent);
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);

                TestProgressLogger.StartTest();
                // Place buy and sell order to set the last price
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketBegin, limitPrice));
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, sellOrderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketEnd, limitPrice));

                // Place Limit sell order to set the market
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                userCommonFunction.CancelAndPlaceLimitSellOrder(driver, instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                userFunctions.LogOut();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER11);
                // Place Market buy order with the same quantity as that of sell limit order placed
                placeMarketBuyOrder = orderEntryPage.PlaceMarketBuyOrder(instrument, buyTab, Double.Parse(marketOrderBuyAmount));
                // Verify order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(placeMarketBuyOrder["Instrument"], placeMarketBuyOrder["Side"], Double.Parse(placeMarketBuyOrder["BuyAmount"]), feeValue, placeMarketBuyOrder["PlaceOrderTime"], placeMarketBuyOrder["PlaceOrderTimePlusOneMin"]), Const.MarketOrderVerifiedInFilledOrders);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketOrderTestPassed, buyTab));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.MarketOrderTestFailed, buyTab), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.MarketOrderTestFailed, buyTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
        [Fact] //
        public void TC2_VerifyAmountPersistence()
        {
            try
            {
                instrument = TestData.GetData("Instrument");
                buyTab     = TestData.GetData("BuyTab");
                sellTab    = TestData.GetData("SellTab");

                TestProgressLogger.StartTest();
                UserFunctions userFunctions = new UserFunctions(TestProgressLogger);
                userFunctions.LogIn(TestProgressLogger, Const.USER5);
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, TestProgressLogger);
                Assert.True(orderEntryPage.VerifyOrderEntryAmountPersistence(instrument, TestData.GetData("PersistenceTestAmount")), LogMessage.DataNotBeingPersisted);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.AmountPersistenceSuccessMsg, buyTab, sellTab));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(Const.AmountPersistenceFailureMsg, ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(Const.AmountPersistenceFailureMsg, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
                UserFunctions userFunctionality = new UserFunctions(TestProgressLogger);
                userFunctionality.LogOut();
            }
        }
        public void TC7_VerifyBuyStopOrder()
        {
            try
            {
                string type = Const.StopMarket;
                instrument   = TestData.GetData("Instrument");
                feeComponent = TestData.GetData("FeeComponent");
                orderType    = TestData.GetData("OrderType");
                menuTab      = TestData.GetData("MenuTab");
                buyTab       = TestData.GetData("BuyTab");
                sellTab      = TestData.GetData("SellTab");
                orderSize    = TestData.GetData("TC7_OrderSize");
                limitPrice   = TestData.GetData("TC7_LimitPrice");
                timeInForce  = TestData.GetData("TimeInForce");
                stopPrice    = TestData.GetData("TC7_StopPrice");

                TestProgressLogger.StartTest();
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);

                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, orderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                string askPrice = userCommonFunction.CancelAndPlaceLimitSellOrder(driver, instrument, sellTab, orderSize, limitPrice, timeInForce);
                UserCommonFunctions.ConfirmWindowOrder(askPrice, limitPrice, driver);
                userFunctions.LogOut();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, sellTab, orderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                Dictionary <string, string> placeStopBuyOrder = orderEntryPage.PlaceStopBuyOrder(instrument, buyTab, Double.Parse(orderSize), Double.Parse(feeComponent), Double.Parse(stopPrice));
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(placeStopBuyOrder["Instrument"], placeStopBuyOrder["Side"], type, Double.Parse(placeStopBuyOrder["BuyAmount"]), placeStopBuyOrder["StopPrice"], placeStopBuyOrder["PlaceOrderTime"], placeStopBuyOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.BuyStopOrderSuccessMsg, buyTab));

                // This cancels all the previous open orders
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER8);
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER9);
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(LogMessage.MarketOrderTestFailed, ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(LogMessage.MarketOrderTestFailed, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
                UserFunctions userFunctionality = new UserFunctions(TestProgressLogger);
                userFunctionality.LogOut();
            }
        }
Ejemplo n.º 4
0
        // This method will verify the order placed in Filled orders tab through Order Entry
        public bool VerifyFilledOrdersTab(string instrument, string side, double size, string fee, string placeOrderTime, string placeOrderTimePlusOneMin)
        {
            string lastPrice;
            double doubleLastPrice;
            string expectedRow_1;
            string currencyText;
            string totalAmountCalculated;
            string buyAmountValue;
            double feeValueInDouble;
            string feeValue;
            string expectedRow_2;

            try
            {
                var            flag           = false;
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);
                buyAmountValue   = GenericUtils.ConvertToDoubleFormat(size);
                feeValueInDouble = Double.Parse(fee);
                feeValue         = GenericUtils.ConvertToDoubleFormat(feeValueInDouble);
                if (side.Equals(TestData.GetData("BuyTab")))
                {
                    orderEntryPage.SelectBuyLimitButton();
                    currencyText = AmountCurrencyNameText();
                }
                else
                {
                    orderEntryPage.SelectSellLimitButton();
                    currencyText = PriceCurrencyNameText();
                }

                lastPrice             = orderEntryPage.GetLastPrice();
                doubleLastPrice       = Convert.ToDouble(lastPrice);
                totalAmountCalculated = GenericUtils.FilledOrdersTotalAmount(size, doubleLastPrice);
                Thread.Sleep(2000);
                UserCommonFunctions.FilledOrderTab(driver);
                expectedRow_1 = instrument + " || " + side + " || " + buyAmountValue + " || " + lastPrice + " || " + totalAmountCalculated + " || " + feeValue + " " + currencyText;
                expectedRow_2 = instrument + " || " + side + " || " + buyAmountValue + " || " + lastPrice + " || " + totalAmountCalculated + " || " + feeValue + " " + currencyText;
                var filledOrdersList = GetListOfFilledOrders();
                if (filledOrdersList.Contains(expectedRow_1) || filledOrdersList.Contains(expectedRow_2))
                {
                    flag = true;
                }
                if (flag)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderVerifiedInFilledOrdersTab, side));
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderNotFoundInFilledOrdersTab, side));
                }
                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        // This method will verify the order placed in Filled orders tab through Order Entry
        public bool VerifyFilledOrdersTabForBuyAndSell(string instrument, string side, double size, string fee, string placeOrderTime, string placeOrderTimePlusOneMin)
        {
            var    flag = false;
            string currencyText;
            string buyAmountValue;
            string lastPrice;
            double doubleLastPrice;
            string totalAmountCalculated;
            string expectedRow_1;

            try
            {
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);
                buyAmountValue = GenericUtils.ConvertToDoubleFormat(size);
                if (side.Equals(TestData.GetData("BuyTab")))
                {
                    orderEntryPage.SelectBuyLimitButton();
                    currencyText = AmountCurrencyNameText();
                }
                else
                {
                    orderEntryPage.SelectSellLimitButton();
                    currencyText = PriceCurrencyNameText();
                }

                lastPrice             = orderEntryPage.GetLastPrice();
                doubleLastPrice       = Convert.ToDouble(lastPrice);
                totalAmountCalculated = GenericUtils.FilledOrdersTotalAmount(size, doubleLastPrice);
                Thread.Sleep(2000);

                // Click on Filled order tab
                UserCommonFunctions.FilledOrderTab(driver);
                expectedRow_1 = instrument + " || " + side + " || " + buyAmountValue + " || " + lastPrice + " || " + totalAmountCalculated + " || " + fee + " " + currencyText;
                var filledOrdersList = GetListOfFilledOrders();
                if (filledOrdersList.Contains(expectedRow_1))
                {
                    flag = true;
                }

                // This will verify the expected details with actual in filled orders tab
                if (flag)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderPresentInFilledOrderTabPassed, side));
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderPresentInFilledOrderTabFailed, side));
                }
                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //This method is a prerequisite for cancelling all existing orders and placing a buy limit order
        public string CancelAndPlaceLimitBuyOrder(IWebDriver driver, string instrument, string buyTab, string orderSize, string limitPrice, string timeInForce)
        {
            string askPrice;

            logger.LogCheckPoint(String.Format(LogMessage.MarketSetupBegin, buyTab, orderSize, limitPrice));
            OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);

            orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, orderSize, limitPrice, timeInForce);
            askPrice = AskPrice(driver).Text;
            return(askPrice);
        }
        public void TC4_VerifySellMarketOrder()
        {
            try
            {
                instrument            = TestData.GetData("Instrument");
                marketOrderSellAmount = TestData.GetData("TC4_MarketOrderSellAmount");
                feeComponent          = TestData.GetData("FeeComponent");
                orderType             = TestData.GetData("OrderType");
                menuTab      = TestData.GetData("MenuTab");
                buyTab       = TestData.GetData("BuyTab");
                sellTab      = TestData.GetData("SellTab");
                buyOrderSize = TestData.GetData("TC4_MarketOrderBuyAmount");
                limitPrice   = TestData.GetData("TC4_LimitPrice");
                timeInForce  = TestData.GetData("TimeInForce");


                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);
                string feeValue = GenericUtils.SellFeeAmount(buyOrderSize, limitPrice, feeComponent);

                TestProgressLogger.StartTest();
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, buyOrderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                userCommonFunction.CancelAndPlaceLimitBuyOrder(driver, instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                userFunctions.LogOut();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, buyTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER11);
                Dictionary <string, string> placeMarketSellOrder = orderEntryPage.PlaceMarketSellOrder(instrument, sellTab, Double.Parse(marketOrderSellAmount), Double.Parse(feeComponent));
                VerifyOrdersTab             objVerifyOrdersTab   = new VerifyOrdersTab(driver, TestProgressLogger);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(placeMarketSellOrder["Instrument"], placeMarketSellOrder["Side"], Double.Parse(placeMarketSellOrder["SellAmount"]), feeValue, placeMarketSellOrder["PlaceOrderTime"], placeMarketSellOrder["PlaceOrderTimePlusOneMin"]), Const.MarketOrderVerifiedInFilledOrders);
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.SellMarketOrderSuccessMsg));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(LogMessage.MarketOrderTestFailed, ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(LogMessage.MarketOrderTestFailed, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
                UserFunctions userFunctionality = new UserFunctions(TestProgressLogger);
                userFunctionality.LogOut();
            }
        }
Ejemplo n.º 8
0
        public void Setup()
        {
            Driver = new Driver(Driver.BrowserType.Chrome);
            Driver.WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
            Driver.WebDriver.Manage().Window.Maximize();

            LoginPage      = new LoginPage(Driver);
            MainPage       = new MainPage(Driver);
            OrderEntryPage = new OrderEntryPage(Driver);

            ExtentHelper.AddTest(TestContext.CurrentContext);
        }
Ejemplo n.º 9
0
        //This method will verify the order placed in Open orders tab through Order Entry
        public bool VerifyOpenOrdersTab(string instrument, string side, double sizeAmount, double stopPrice)
        {
            try {
                var    flag = false;
                string marketStopOrderTime = null;

                UserFunctions userfuntionality = new UserFunctions(output);
                userfuntionality.LogIn(logger);

                UserCommonFunctions.DashBoardMenuButton(driver);
                Thread.Sleep(2000);
                UserCommonFunctions.SelectAnExchange(driver);

                OrderEntryPage boe = new OrderEntryPage(driver, output);

                if (side.Equals("Buy"))
                {
                    marketStopOrderTime = boe.PlaceStopBuyOrder(sizeAmount, stopPrice);
                }
                else if (side.Equals("Sell"))
                {
                    marketStopOrderTime = boe.PlaceStopSellOrder(sizeAmount, stopPrice);
                }
                string buyAmountValue        = GenericUtils.ConvertToDoubleFormat(sizeAmount);
                string lastPrice             = boe.GetLastPrice();
                double doubleLastPrice       = Convert.ToDouble(lastPrice);
                string totalAmountCalculated = GenericUtils.FilledOrdersTotalAmount(sizeAmount, doubleLastPrice);

                UserCommonFunctions.OpenOrderTab(driver);

                string expectedRow = instrument + " || " + side + " || " + sizeAmount + " || " + lastPrice + " || " + totalAmountCalculated + " || " + marketStopOrderTime;

                if (GetListOfFilledOrders().Contains(expectedRow))
                {
                    logger.Info(side + "Order Successfully verifed in Open orders tab");
                    flag = true;
                }
                return(flag);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 10
0
        //This method will verify the Block Trade Trade Report of Other Party
        public void VerifyOtherPartyBlockTradeReportTab(string instrument, string sellTab, string counterPartyValue, string productBoughtPrice, string productSoldPrice, string status, Dictionary <string, string> otherPartyBlockTradeData)
        {
            OrderEntryPage orderEntryPage  = new OrderEntryPage(driver, logger);
            string         lastPrice       = orderEntryPage.GetLastPrice();
            var            blockTradePrice = GetBlockTradePrice(productBoughtPrice, productSoldPrice);
            double         feeValue        = (Double.Parse(productBoughtPrice) * Double.Parse(lastPrice)) / 25;
            string         feeValueText    = GenericUtils.ConvertToDoubleFormat(feeValue);

            try
            {
                VerifyOrdersTab objVerifyOrdersTab = new VerifyOrdersTab(driver, logger);
                objVerifyOrdersTab.VerifyTradeReportsTab(instrument, sellTab, productBoughtPrice, blockTradePrice, feeValueText, otherPartyBlockTradeData["PlaceBlockTradeTime"], otherPartyBlockTradeData["PlaceBlockTradeTimePlusOneMin"], status);
                logger.LogCheckPoint(String.Format(LogMessage.SellBlockTradeReportTestPassed, sellTab));
            }
            catch (Exception)
            {
                logger.LogCheckPoint(String.Format(LogMessage.SellBlockTradeReportTestFailed, sellTab));
            }
        }
Ejemplo n.º 11
0
 public void VerifyPricePersistancy()
 {
     try
     {
         UserFunctions userfuntionality = new UserFunctions(output);
         userfuntionality.LogIn(logger);
         OrderEntryPage orderEntryPage = new OrderEntryPage(driver, output);
         Assert.True(orderEntryPage.VerifyOrderEntryAmountPersistence("20"));
         logger.Info("Market amount persistence test passed successfully");
     }
     catch (Exception e)
     {
         logger.Error("Market Amount Persistence Test Failed");
         logger.Error(e.StackTrace);
         throw e;
     }
     finally
     {
         UserFunctions userFunctionality = new UserFunctions(output);
         userFunctionality.LogOut();
     }
 }
Ejemplo n.º 12
0
        //This method will perform buy trade report(Will be use by TC_35)
        public void SubmitBlockTradeReportForUser(string counterPartyPrice, string producBoughtPrice, string productSoldPrice)
        {
            try
            {
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);
                //ReportBlockTradeButton();
                UserSetFunctions.EnterText(CounterPartyTextField(), counterPartyPrice);
                UserSetFunctions.EnterText(ProductBoughtTextField(), producBoughtPrice);
                UserSetFunctions.EnterText(ProductSoldTextField(), productSoldPrice);
                Thread.Sleep(2000);
                SubmitReportButton();
                Thread.Sleep(2000);
                ConfirmSubmitReportButton();
                Thread.Sleep(2000);
                string expectedBuyTradeReportOrderMsg = BuyTradeReportOrderMsg().Text;
                string actualCancelMsg = UserCommonFunctions.GetTextOfMessage(driver, logger);

                string actualBuyTradeReportOrderMsg = string.Format(LogMessage.BuyTradeReportOrderMesgSuccess);
                string expectedCancelMsg            = string.Format(LogMessage.BuyTradeReportOrderMesgCanceled);
                try
                {
                    Assert.Equal(expectedBuyTradeReportOrderMsg, actualBuyTradeReportOrderMsg);
                    logger.LogCheckPoint(string.Format(LogMessage.BuyTradeReportOrderMesgSuccess));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.BuyTradeReportOrderMesgCanceled));
                }
                Thread.Sleep(2000);
                UserSetFunctions.Click(CloseReportBlockTradeWindowSection());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 13
0
        public void TC49_VerifyLoyalityFeeBuyMarketOrderTest()
        {
            instrument           = TestData.GetData("Instrument");
            buyTab               = TestData.GetData("BuyTab");
            accountID            = TestData.GetData("TC49_AccountID");
            buyMarketOrderAmount = TestData.GetData("TC49_BuyMarketOrderAmount");

            UserFunctions        userFuntions            = new UserFunctions(TestProgressLogger);
            AdminFunctions       objAdminFunctions       = new AdminFunctions(TestProgressLogger);
            AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(TestProgressLogger);
            UserCommonFunctions  userCommonFunctions     = new UserCommonFunctions(TestProgressLogger);
            LoyaltyTokenPage     loyaltyTokenPage        = new LoyaltyTokenPage(TestProgressLogger);
            OrderEntryPage       orderEnteryPage         = new OrderEntryPage(driver, TestProgressLogger);

            try
            {
                TestProgressLogger.StartTest();
                // The admin will enabled the loyalty fee(LTC) to the user
                // Login as admin
                objAdminFunctions.AdminLogIn(TestProgressLogger);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.AdminLoyaltyFeeCheckStart, accountID));
                objAdminCommonFunctions.SelectAccountsMenu();
                // Enter accountID  in "Open Account by ID" textbox of the user for which Loyalty Fee should be applied
                objAdminCommonFunctions.OpenAccountByIDText(accountID);
                // Click on "Open" button
                objAdminCommonFunctions.OpenAccountBtn();
                // Click on "Edit Account Information" link
                objAdminCommonFunctions.EditInformationButton();
                // Click on "Loyalty Fees Enabled(LTC)" checkbox button. This will enable Fees to be deducted int the form of LTC
                objAdminCommonFunctions.LoyaltyFeeCheckedOrUnchecked();
                objAdminCommonFunctions.SaveButton();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.AdminLoyaltyFeeCheckCompleted, accountID));
                objAdminCommonFunctions.UserMenuBtn();
                // Admin LogOut
                objAdminFunctions.AdminLogOut();

                // This will verify whether the Fee applied is in the form of LTC
                // Login as User for which Loyalty Fees Enabled(LTC) was selected
                // Navigate to UserSetting -> Loyalty Token -> Select Radio Button for LTC
                userFuntions.LogIn(TestProgressLogger, Const.USER13);
                UserCommonFunctions.DashBoardMenuButton(driver);
                UserCommonFunctions.NavigateToUserSetting(driver);
                loyaltyTokenPage.LoyaltyTokenButton(driver);
                loyaltyTokenPage.TradingFeeRadioButton(driver);
                loyaltyTokenPage.UserSettingMenuButton(driver);
                TestProgressLogger.LogCheckPoint(LogMessage.SelectLoyaltyTokenSuccess);
                // Navigate to Exchange -> Order Entry -> Enter Buy Amount
                UserCommonFunctions.SelectAnExchange(driver);
                UserCommonFunctions.SelectInstrumentFromExchange(instrument, driver);
                orderEnteryPage.MarketOrderTypeBtn();
                orderEnteryPage.EnterBuyAmount(buyMarketOrderAmount);

                // Verify Fees displayed is in the form of LTC
                Assert.True(loyaltyTokenPage.GetFeeText());
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.VerifyAppliedFeeIsLTC, buyTab));
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.LoyaltyTokenSuccessMsg, buyTab));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.LoyaltyTokenFailureMsg, buyTab), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.LoyaltyTokenFailureMsg, buyTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
        public void TC6_VerifySellLimitOrder()
        {
            try
            {
                string type;
                string buyOrderFeeValue;
                string sellOrderFeeValue;
                instrument      = TestData.GetData("Instrument");
                orderType       = TestData.GetData("OrderType");
                menuTab         = TestData.GetData("MenuTab");
                buyTab          = TestData.GetData("BuyTab");
                sellTab         = TestData.GetData("SellTab");
                buyOrderSize    = TestData.GetData("TC6_BuyOrderSize");
                sellOrderSize   = TestData.GetData("TC6_SellOrderSize");
                incBuyOrderSize = TestData.GetData("TC6_IncreasedBuyOrderSize");
                decBuyOrderSize = TestData.GetData("TC6_DecreasedBuyOrderSize");
                limitPrice      = TestData.GetData("TC6_LimitPrice");
                timeInForce     = TestData.GetData("TC6_TimeInForce");
                feeComponent    = TestData.GetData("FeeComponent");

                type              = Const.Limit;
                buyOrderFeeValue  = GenericUtils.FeeAmount(buyOrderSize, feeComponent);
                sellOrderFeeValue = GenericUtils.SellFeeAmount(sellOrderSize, limitPrice, feeComponent);

                TestProgressLogger.StartTest();
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);

                // Creating Buy and Sell Order to get the last price
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, buyOrderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);

                // Scenario 1: Buy order B1 with same price is available and B1 quantity is = S1.
                userFunctions.LogIn(TestProgressLogger, Const.USER8);

                Dictionary <string, string> placeLimitSellOrder = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, sellTab, type, Double.Parse(sellOrderSize), limitPrice, placeLimitSellOrder["PlaceOrderTime"], placeLimitSellOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                Dictionary <string, string> placeLimitBuyOrder = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(buyOrderSize), buyOrderFeeValue, placeLimitBuyOrder["PlaceOrderTime"], placeLimitBuyOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(sellOrderSize), sellOrderFeeValue, placeLimitSellOrder["PlaceOrderTime"], placeLimitSellOrder["PlaceOrderTimePlusOneMin"]));

                // Scenario 2: Buy order B1 with same price is available and B1 quantity is > S1.
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                Dictionary <string, string> placeLimitSellOrderS2 = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, sellTab, type, Double.Parse(sellOrderSize), limitPrice, placeLimitSellOrderS2["PlaceOrderTime"], placeLimitSellOrderS2["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                Dictionary <string, string> placeLimitBuyOrderS2 = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, incBuyOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(sellOrderSize), buyOrderFeeValue, placeLimitSellOrderS2["PlaceOrderTime"], placeLimitSellOrderS2["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, incBuyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(sellOrderSize), sellOrderFeeValue, placeLimitSellOrderS2["PlaceOrderTime"], placeLimitSellOrderS2["PlaceOrderTimePlusOneMin"]));


                // Scenario 3: Buy order B1 with same price is available and B1 quantity is < S1.
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER9);
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                Dictionary <string, string> placeLimitSellOrderS3 = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, sellTab, type, Double.Parse(sellOrderSize), limitPrice, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                buyOrderFeeValue = GenericUtils.FeeAmount(decBuyOrderSize, feeComponent);
                Dictionary <string, string> placeLimitBuyOrderS3 = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, decBuyOrderSize, limitPrice, timeInForce);
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(decBuyOrderSize), buyOrderFeeValue, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, decBuyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                sellOrderFeeValue = GenericUtils.SellFeeAmount(decBuyOrderSize, limitPrice, feeComponent);
                string orderSizeDifference = GenericUtils.GetDifferenceFromStringAfterSubstraction(sellOrderSize, decBuyOrderSize);
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, sellTab, type, Double.Parse(orderSizeDifference), limitPrice, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(decBuyOrderSize), sellOrderFeeValue, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));

                // This step cancels the remaining order and verifies the same in Open orders tab
                UserCommonFunctions.CancelOrderBookSellOrder(driver);
                Assert.False(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, sellTab, type, Double.Parse(orderSizeDifference), limitPrice, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.Error(LogMessage.MarketOrderTestFailed, e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
Ejemplo n.º 15
0
        //This method will perform a simple Block Buy trade operation(Used for TC_34)
        public void SubmitBlockTradeReportWithoutLockedInCheckBox(string instrument, string counterPartyValue, string producBoughtPrice, string productSoldPrice, string counterPartyPrice, string buyTab, string status)
        {
            placeBlockTradeDateTimeOfBlockTrade           = TestData.GetData("TC34_PlaceBlockTradeTime");
            placeBlockTradeDateTimePlusOneMinOfBlockTrade = TestData.GetData("TC34_PlaceBlockTradeTimePlusOneMin");
            typeValue   = TestData.GetData("TC34_Type");
            statusValue = TestData.GetData("TC34_Status");
            cancelValue = TestData.GetData("TC35_Cancel");
            try
            {
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);
                UserSetFunctions.EnterText(CounterPartyTextField(), counterPartyPrice);
                UserSetFunctions.EnterText(ProductBoughtTextField(), producBoughtPrice);
                UserSetFunctions.EnterText(ProductSoldTextField(), productSoldPrice);
                Thread.Sleep(2000);
                string productBought       = ProductBoughtTextField().GetAttribute(string.Format(LogMessage.ProductBoughtTextFieldAttributeValue));
                double actualProductBought = double.Parse(productBought);

                string productSold       = ProductSoldTextField().GetAttribute(string.Format(LogMessage.ProductSoldTextFieldAttributeValue));
                double actualProductSold = double.Parse(productSold);

                string orderTotalAmountStringValue = OrderTotalAmount().Text;
                string orderTotalAmountdigits      = orderTotalAmountStringValue.Split(" ")[1];
                double doubleOrderTotalPrice       = Double.Parse(orderTotalAmountdigits);

                string receivedAmountStringValue = ReceivedAmount().Text;
                string receivedAmountdigits      = receivedAmountStringValue.Split(" ")[1];
                double doubleReceivedPrice       = Double.Parse(receivedAmountdigits);

                string feeAmountStringValue = FeeAmount().Text;
                string feeAmountdigits      = feeAmountStringValue.Split(" ")[1];
                double doubleFeePrice       = Double.Parse(feeAmountdigits);

                double receivedBTCAmount = actualProductBought - doubleFeePrice;

                //This will verify if product Sold is equal to Order Total amount.
                try
                {
                    Assert.Equal(actualProductSold, doubleOrderTotalPrice);
                    logger.LogCheckPoint(string.Format(LogMessage.ProductSoldEqualsToOrderTotal, actualProductSold, doubleOrderTotalPrice));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.ProductSoldNotEqualsToOrderTotal, actualProductBought, doubleOrderTotalPrice));
                }

                //This will verify if Receiver amount is deducted after fee.
                try
                {
                    Assert.Equal(receivedBTCAmount, doubleOrderTotalPrice);
                    logger.LogCheckPoint(string.Format(LogMessage.VerifiedReceivedBTCAmountAfterFeeDeductingPassed, receivedBTCAmount, actualProductBought));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.VerifiedReceivedBTCAmountAfterFeeDeductingFailed, receivedBTCAmount, doubleFeePrice));
                }
                Thread.Sleep(2000);
                SubmitReportButton();
                Thread.Sleep(2000);
                VerifyFinalAmountAndFinalValue();
                string feeValueText    = LabelConfirmBlockTradeFeeValue().Text;
                var    blockTradePrice = GetBlockTradePrice(producBoughtPrice, productSoldPrice);
                //string dateText;
                //string expectedBlockTradeDate;
                //Dictionary<string, string> placeBlockTradeReportOrder = new Dictionary<string, string>();
                //dateText = LabelConfirmBlockTradeDate().Text;
                //expectedBlockTradeDate = dateText;
                //string actualBlockTradeDate = GenericUtils.GetCurrentTime();
                //string actualBlockTradeDatePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute();
                //placeBlockTradeReportOrder.Add(placeBlockTradeDateTimeOfBlockTrade, actualBlockTradeDate);
                //placeBlockTradeReportOrder.Add(placeBlockTradeDateTimePlusOneMinOfBlockTrade, actualBlockTradeDatePlusOneMin);
                Thread.Sleep(2000);
                ConfirmSubmitReportButton();
                Thread.Sleep(2000);
                string expectedBuyTradeReportOrderMsg = BuyTradeReportOrderMsg().Text;
                string actualCancelMsg = UserCommonFunctions.GetTextOfMessage(driver, logger);
                string actualBuyTradeReportOrderMsg = String.Format(LogMessage.BuyTradeReportOrderMesgSuccess);
                string expectedCancelMsg            = String.Format(LogMessage.BuyTradeReportOrderMesgCanceled);
                try
                {
                    Assert.Equal(expectedBuyTradeReportOrderMsg, actualBuyTradeReportOrderMsg);
                    logger.LogCheckPoint(string.Format(LogMessage.BuyTradeReportOrderMesgSuccess));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.BuyTradeReportOrderMesgCanceled));
                }

                Thread.Sleep(2000);
                UserSetFunctions.Click(CloseReportBlockTradeWindowSection());
                try
                {
                    VerifyOrdersTab objVerifyOrdersTab = new VerifyOrdersTab(driver, logger);
                    //Need to create a logic to cehck if block trade oorder comings in open trade order
                    objVerifyOrdersTab.VerifyBlockTradeReportsInOpenOrderTab(instrument, buyTab, typeValue, producBoughtPrice, blockTradePrice, statusValue, cancelValue);
                    logger.LogCheckPoint(String.Format(LogMessage.BuyBlockTradeReportInOpenTabWithWorkingStatusPassed, buyTab));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.BuyBlockTradeReportInOpenTabWithWorkingStatusFailed, buyTab));
                }
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 16
0
        public void TC8_VerifySellStopOrder()
        {
            try
            {
                string type = Const.StopMarket;
                instrument    = TestData.GetData("Instrument");
                feeComponent  = TestData.GetData("FeeComponent");
                orderType     = TestData.GetData("OrderType");
                menuTab       = TestData.GetData("MenuTab");
                buyTab        = TestData.GetData("BuyTab");
                sellTab       = TestData.GetData("SellTab");
                orderSize     = TestData.GetData("TC8_OrderSize");
                limitPrice    = TestData.GetData("TC8_LimitPrice");
                timeInForce   = TestData.GetData("TimeInForce");
                sellStopPrice = TestData.GetData("TC8_StopPrice");
                Dictionary <string, string> placeStopSellOrder;
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);

                TestProgressLogger.StartTest();
                // Place buy and sell order to set the last price
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketBegin, limitPrice));
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, orderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketEnd, limitPrice));

                // Place Limit Buy order to set the market
                userFunctions.LogIn(TestProgressLogger, Const.USER11);
                userCommonFunction.CancelAndPlaceLimitBuyOrder(driver, instrument, buyTab, orderSize, limitPrice, timeInForce);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, buyTab, orderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER5);
                // Place Stop Buy order with Stop Price < market price
                placeStopSellOrder = orderEntryPage.PlaceStopSellOrder(instrument, sellTab, Double.Parse(orderSize), Double.Parse(feeComponent), Double.Parse(sellStopPrice));

                // Verify that the order is present in the Open Orders tab
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(placeStopSellOrder["Instrument"], placeStopSellOrder["Side"], type, Double.Parse(placeStopSellOrder["SellAmount"]), placeStopSellOrder["StopPrice"], placeStopSellOrder["PlaceOrderTime"], placeStopSellOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.BuyStopOrderSuccessMsg, sellTab));

                // This cancels all the previous open orders
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER11);
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER5);
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.StopOrderTestFailed, sellTab), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.StopOrderTestFailed, sellTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
Ejemplo n.º 17
0
        public void TC5_VerifyBuyLimitOrder()
        {
            try
            {
                string type;
                string buyOrderFeeValue;
                string sellOrderFeeValue;
                Dictionary <string, string> placeLimitBuyOrder;
                Dictionary <string, string> placeLimitSellOrder;
                string orderSizeDifference;
                instrument       = TestData.GetData("Instrument");
                orderType        = TestData.GetData("OrderType");
                menuTab          = TestData.GetData("MenuTab");
                buyTab           = TestData.GetData("BuyTab");
                sellTab          = TestData.GetData("SellTab");
                buyOrderSize     = TestData.GetData("TC5_BuyOrderSize");
                sellOrderSize    = TestData.GetData("TC5_SellOrderSize");
                incSellOrderSize = TestData.GetData("TC5_IncreasedSellOrderSize");
                decSellOrderSize = TestData.GetData("TC5_DecreasedSellOrderSize");
                limitPrice       = TestData.GetData("TC5_LimitPrice");
                timeInForce      = TestData.GetData("TC5_TimeInForce");
                feeComponent     = TestData.GetData("FeeComponent");
                type             = Const.Limit;
                // Get fee for buy order based on buy amount and fee component
                buyOrderFeeValue = GenericUtils.FeeAmount(buyOrderSize, feeComponent);
                // Get fee for sell order based on buy amount, limit price and fee component
                sellOrderFeeValue = GenericUtils.SellFeeAmount(sellOrderSize, limitPrice, feeComponent);

                TestProgressLogger.StartTest();
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);

                // Place buy and sell order to set the last price
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketBegin, limitPrice));
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, buyOrderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketEnd, limitPrice));

                // Scenario 1: Sell order S1 with same price is available and S1 quantity is = B1.
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                // Place Buy order to set the market
                placeLimitBuyOrder = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                // Verify that the order is present in the Open Orders tab
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, buyTab, type, Double.Parse(buyOrderSize), limitPrice, placeLimitBuyOrder["PlaceOrderTime"], placeLimitBuyOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                // Place Limit sell order with the same price and quantity as Buy order to verify the order gets filled
                placeLimitSellOrder = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                // Verify sell order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(sellOrderSize), sellOrderFeeValue, placeLimitSellOrder["PlaceOrderTime"], placeLimitSellOrder["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                // Verify buy order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(buyOrderSize), buyOrderFeeValue, placeLimitSellOrder["PlaceOrderTime"], placeLimitSellOrder["PlaceOrderTimePlusOneMin"]));

                // Scenario 2: Sell order S1 with same price is available and S1 quantity is > B1.
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                // Place Buy order to set the market
                Dictionary <string, string> placeLimitBuyOrderS2 = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                // Verify that the order is present in the Open Orders tab
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, buyTab, type, Double.Parse(buyOrderSize), limitPrice, placeLimitBuyOrderS2["PlaceOrderTime"], placeLimitBuyOrderS2["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                // Place Limit sell order with the same price and quantity > Buy order to verify the order gets filled
                Dictionary <string, string> placeLimitSellOrderS2 = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, incSellOrderSize, limitPrice, timeInForce);
                // Verify sell order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(buyOrderSize), sellOrderFeeValue, placeLimitSellOrderS2["PlaceOrderTime"], placeLimitSellOrderS2["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                // Verify buy order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(buyOrderSize), buyOrderFeeValue, placeLimitSellOrderS2["PlaceOrderTime"], placeLimitSellOrderS2["PlaceOrderTimePlusOneMin"]));

                // Scenario 3: Sell order S1 with same price is available and S1 quantity is < B1.
                UserCommonFunctions.LoginAndCancelAllOrders(TestProgressLogger, driver, instrument, Const.USER9);
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                // Place Buy order to set the market
                Dictionary <string, string> placeLimitBuyOrderS3 = orderEntryPage.PlaceLimitBuyOrder(instrument, buyTab, buyOrderSize, limitPrice, timeInForce);
                // Verify that the order is present in the Open Orders tab
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, buyTab, type, Double.Parse(buyOrderSize), limitPrice, placeLimitBuyOrderS3["PlaceOrderTime"], placeLimitBuyOrderS3["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, buyTab, buyOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER9);
                sellOrderFeeValue = GenericUtils.SellFeeAmount(decSellOrderSize, limitPrice, feeComponent);
                // Place Limit sell order with the same price and quantity < Buy order to verify the order gets filled
                Dictionary <string, string> placeLimitSellOrderS3 = orderEntryPage.PlaceLimitSellOrder(instrument, sellTab, decSellOrderSize, limitPrice, timeInForce);
                // Verify order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, sellTab, Double.Parse(decSellOrderSize), sellOrderFeeValue, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
                TestProgressLogger.LogCheckPoint(string.Format(LogMessage.LimitOrderSuccessMsg, sellTab, decSellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                orderEntryPage.NavigateToHomePage(instrument);
                // This will get the fee value based on decreased order size
                buyOrderFeeValue = GenericUtils.FeeAmount(decSellOrderSize, feeComponent);
                // Get the difference between the buy and sell order sizes
                orderSizeDifference = GenericUtils.GetDifferenceFromStringAfterSubstraction(buyOrderSize, decSellOrderSize);
                // Verify that the order is present in the Open Orders tab
                Assert.True(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, buyTab, type, Double.Parse(orderSizeDifference), limitPrice, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
                // Verify order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(instrument, buyTab, Double.Parse(decSellOrderSize), buyOrderFeeValue, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));

                // This step cancels the remaining order and verifies the same in Open orders tab
                UserCommonFunctions.CancelOrderBookBuyOrder(driver);
                UserCommonFunctions.OpenOrderTab(driver);
                // Verify that the order is not present in the Open Orders tab
                Assert.False(objVerifyOrdersTab.VerifyOpenOrdersTab(instrument, buyTab, type, Double.Parse(orderSizeDifference), limitPrice, placeLimitSellOrderS3["PlaceOrderTime"], placeLimitSellOrderS3["PlaceOrderTimePlusOneMin"]));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.LimitOrderTestFailed, buyTab), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.LimitOrderTestFailed, buyTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
Ejemplo n.º 18
0
        //This method will perform a simple Block Buy trade operation and verify the fields(Used for TC_33)
        public void VerifyElementsAndSubmitBlockTradeReport(string counterPartyPrice, string wrongCounterPrice, string producBoughtPrice, string productSoldPrice)
        {
            string ExpectedCounterPartyMsg = string.Format(LogMessage.CounterPartyErrorMsgVerified, wrongCounterPrice);

            try
            {
                OrderEntryPage orderEntryPage = new OrderEntryPage(driver, logger);
                UserSetFunctions.EnterText(CounterPartyTextField(), wrongCounterPrice);
                UserSetFunctions.EnterText(ProductBoughtTextField(), producBoughtPrice);
                UserSetFunctions.EnterText(ProductSoldTextField(), productSoldPrice);
                Thread.Sleep(2000);
                SubmitReportButton();
                Thread.Sleep(2000);
                ConfirmSubmitReportButton();
                string AcceptedCountrPartyErrorMsg = CounterPartyErrorMsg().Text;

                //This will verify if the counterParty error message is coming
                try
                {
                    Assert.Equal(ExpectedCounterPartyMsg, AcceptedCountrPartyErrorMsg);
                    logger.LogCheckPoint(string.Format(LogMessage.CounterPartyErrorMsgVerified, wrongCounterPrice));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.CounterPartyErrorMsgVerified));
                }
                Thread.Sleep(2000);
                UserSetFunctions.Clear(CounterPartyTextField());
                UserSetFunctions.EnterText(CounterPartyTextField(), counterPartyPrice);
                Thread.Sleep(2000);
                LockedInCheckBoxButton();
                Thread.Sleep(2000);
                string productBought       = ProductBoughtTextField().GetAttribute(string.Format(LogMessage.ProductBoughtTextFieldAttributeValue));
                double actualProductBought = double.Parse(productBought);

                string productSold       = ProductSoldTextField().GetAttribute(string.Format(LogMessage.ProductSoldTextFieldAttributeValue));
                double actualProductSold = double.Parse(productSold);

                string orderTotalAmountStringValue = OrderTotalAmount().Text;
                string orderTotalAmountdigits      = orderTotalAmountStringValue.Split(" ")[1];
                double doubleOrderTotalPrice       = Double.Parse(orderTotalAmountdigits);

                string receivedAmountStringValue = ReceivedAmount().Text;
                string receivedAmountdigits      = receivedAmountStringValue.Split(" ")[1];
                double doubleReceivedPrice       = Double.Parse(receivedAmountdigits);

                string feeAmountStringValue = FeeAmount().Text;
                string feeAmountdigits      = feeAmountStringValue.Split(" ")[1];
                double doubleFeePrice       = Double.Parse(feeAmountdigits);

                double receivedBTCAmount = actualProductBought - doubleFeePrice;

                //This will verify if product Sold is equal to Order Total amount.
                try
                {
                    Assert.Equal(actualProductSold, doubleOrderTotalPrice);
                    logger.LogCheckPoint(string.Format(LogMessage.ProductSoldEqualsToOrderTotal, actualProductSold, doubleOrderTotalPrice));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.ProductSoldNotEqualsToOrderTotal, actualProductBought, doubleOrderTotalPrice));
                }

                //This will verify if Receiver amount is deducted after fee.
                try
                {
                    Assert.Equal(receivedBTCAmount, doubleOrderTotalPrice);
                    logger.LogCheckPoint(string.Format(LogMessage.VerifiedReceivedBTCAmountAfterFeeDeductingPassed, receivedBTCAmount, actualProductBought));
                }
                catch (Exception)
                {
                    logger.LogCheckPoint(string.Format(LogMessage.VerifiedReceivedBTCAmountAfterFeeDeductingFailed, receivedBTCAmount, doubleFeePrice));
                }
                Thread.Sleep(2000);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void TC50_VerifyLoyalityFeeSellMarketOrder()
        {
            instrument            = TestData.GetData("Instrument");
            sellTab               = TestData.GetData("SellTab");
            accountID             = TestData.GetData("TC50_AccountID");
            sellMarketOrderAmount = TestData.GetData("TC50_SellMarketOrderAmount");


            UserFunctions        userFuntions            = new UserFunctions(TestProgressLogger);
            AdminFunctions       objAdminFunctions       = new AdminFunctions(TestProgressLogger);
            AdminCommonFunctions objAdminCommonFunctions = new AdminCommonFunctions(TestProgressLogger);
            UserCommonFunctions  userCommonFunctions     = new UserCommonFunctions(TestProgressLogger);
            LoyaltyTokenPage     loyaltyTokenPage        = new LoyaltyTokenPage(TestProgressLogger);
            OrderEntryPage       orderEnteryPage         = new OrderEntryPage(driver, TestProgressLogger);

            try
            {
                TestProgressLogger.StartTest();
                objAdminFunctions.AdminLogIn(TestProgressLogger);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.AdminLoyaltyFeeCheckStart, accountID));
                objAdminCommonFunctions.SelectAccountsMenu();
                objAdminCommonFunctions.OpenAccountByIDText(accountID);
                objAdminCommonFunctions.OpenAccountBtn();
                objAdminCommonFunctions.EditInformationButton();
                objAdminCommonFunctions.LoyaltyFeeCheckedOrUnchecked();
                objAdminCommonFunctions.SaveButton();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.AdminLoyaltyFeeCheckCompleted, accountID));
                objAdminCommonFunctions.UserMenuBtn();
                objAdminFunctions.AdminLogOut();

                userFuntions.LogIn(TestProgressLogger, Const.USER13);
                UserCommonFunctions.DashBoardMenuButton(driver);
                UserCommonFunctions.NavigateToUserSetting(driver);
                loyaltyTokenPage.LoyaltyTokenButton(driver);
                loyaltyTokenPage.TradingFeeRadioButton(driver);
                loyaltyTokenPage.UserSettingMenuButton(driver);
                TestProgressLogger.LogCheckPoint(LogMessage.SelectLoyaltyTokenSuccess);
                UserCommonFunctions.SelectAnExchange(driver);
                UserCommonFunctions.SelectInstrumentFromExchange(instrument, driver);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.VerifyAppliedFeeIsLTC, sellTab));
                orderEnteryPage.SellOrderEntryBtn();
                orderEnteryPage.MarketOrderTypeBtn();
                orderEnteryPage.EnterSellAmount(sellMarketOrderAmount);
                Assert.True(loyaltyTokenPage.GetFeeText());
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.LoyaltyTokenSuccessMsg, sellTab));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(String.Format(LogMessage.LoyaltyTokenFailureMsg, sellTab), ex);
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogError(String.Format(LogMessage.LoyaltyTokenFailureMsg, sellTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
                UserFunctions userFunctionality = new UserFunctions(TestProgressLogger);
                userFunctionality.LogOut();
            }
        }