public bool VerifyNet(string netValue, string amountValue) { string feeCalculated; string netFromUI; string feeInDouble; string feeComponent; string netDifference; string netComponent; string feeExpected; feeComponent = TestData.GetData("FeeComponent"); feeCalculated = GenericUtils.FeeAmount(amountValue, feeComponent); feeInDouble = GenericUtils.ConvertToDoubleFormat(Double.Parse(feeCalculated)); feeExpected = GenericUtils.RemoveCommaFromString(feeInDouble); netFromUI = UserCommonFunctions.GetSplitValue(netValue); netComponent = GenericUtils.RemoveCommaFromString(netFromUI); netDifference = GenericUtils.GetDifferenceFromStringAfterSubstraction(amountValue, feeExpected); if (netDifference.Equals(netComponent)) { return(true); } else { logger.LogCheckPoint(LogMessage.NetVerificationFailed); return(false); } }
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(); } }
public bool VerifyFees(string feeValue, string buyAmountValue) { string feeCalculated; string feeFromUI; string feeInDouble; string feeComponent; string feeToCompare; string feeExpected; feeComponent = TestData.GetData("FeeComponent"); feeCalculated = GenericUtils.FeeAmount(buyAmountValue, feeComponent); feeInDouble = GenericUtils.ConvertToDoubleFormat(Double.Parse(feeCalculated)); feeExpected = GenericUtils.RemoveCommaFromString(feeInDouble); feeFromUI = UserCommonFunctions.GetSplitValue(feeValue); feeToCompare = GenericUtils.RemoveCommaFromString(feeFromUI); if (feeExpected.Equals(feeToCompare)) { return(true); } else { logger.LogCheckPoint(LogMessage.FeesVerificationFailed); return(false); } }
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(); } }
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(); } }