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();
            }
        }
Пример #2
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;
            }
        }