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");

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

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

                userFunctions.LogIn(TestProgressLogger, Const.USER11);
                string askPrice = userCommonFunction.CancelAndPlaceLimitBuyOrder(driver, instrument, buyTab, orderSize, limitPrice, timeInForce);
                UserCommonFunctions.ConfirmWindowOrder(askPrice, limitPrice, driver);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, buyTab, orderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER5);
                Dictionary <string, string> placeStopSellOrder = orderEntryPage.PlaceStopSellOrder(instrument, sellTab, Double.Parse(orderSize), Double.Parse(feeComponent), Double.Parse(sellStopPrice));
                VerifyOrdersTab             objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);
                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.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();
            }
        }
Exemple #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;
            }
        }