//This method will very the details in Trade Report tab TC_33 public Dictionary <string, string> SubmitBuyTradeReport(string instrument, string buyTab, string counterPartyValue, string productBoughtPrice, string productSoldPrice, string status) { try { Dictionary <string, string> placeBlockTradeReportOrder = new Dictionary <string, string>(); var blockTradePrice = GetBlockTradePrice(productBoughtPrice, productSoldPrice); SubmitReportButton(); string feeValueText = LabelConfirmBlockTradeFeeValue().Text; placeBlockTradeReportOrder = VerifyConfirmBlockTradeElements(counterPartyValue, instrument); VerifyFinalAmountAndFinalValue(); ConfirmSubmitReportButton(); 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); objVerifyOrdersTab.VerifyTradeReportsTab(instrument, buyTab, productBoughtPrice, blockTradePrice, feeValueText, placeBlockTradeReportOrder["PlaceBlockTradeTime"], placeBlockTradeReportOrder["PlaceBlockTradeTimePlusOneMin"], status); logger.LogCheckPoint(String.Format(LogMessage.BuyBlockTradeReportTestPassed, buyTab)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.BuyBlockTradeReportTestFailed, buyTab)); } try { Thread.Sleep(2000); if (CancelButton().Enabled) { logger.LogCheckPoint(string.Format(LogMessage.VerifiedCancelButtonFailed)); } } catch (Exception) { logger.LogCheckPoint(string.Format(LogMessage.VerifiedCancelButtonPassed)); } Thread.Sleep(2000); return(placeBlockTradeReportOrder); } catch (Exception e) { throw e; } }
//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)); } }
//This will place an sell order in BuyAndSell page public void PlaceSellOrder(string instrument, string side) { VerifyOrdersTab objVerifyOrdersTab = new VerifyOrdersTab(driver, logger); string bTCBalanceTextValue = BTCBalances().Text; string feeFactor = TestData.GetData("FeeComponent"); double bTCBalanceInDoubleValue = Double.Parse(bTCBalanceTextValue); string actualBTCBalance = GenericUtils.ConvertToDoubleFormat(bTCBalanceInDoubleValue); string usdBalanceTextValue = USDBalances().Text; string usdBalance = usdBalanceTextValue.Split("$")[1]; Thread.Sleep(1000); RadioBtn(); Thread.Sleep(1000); var transactionOverviewDetails = GetSellTransactionOverView(); var priceText = transactionOverviewDetails["Price"].Split(" ")[0];//price amount without any tag string USDCurrency = TestData.GetData("USDCurrency"); string selected100DollarTextValue = selected100USD().Text; string selected100DollarPrice = selected100DollarTextValue.Split("$")[1]; Double selected100DollarDoublePrice = Double.Parse(selected100DollarPrice);//Limit amount without any tag(USD 100) string selected100DollarPriceValue = GenericUtils.ConvertToDoubleFormat(selected100DollarDoublePrice) + " " + USDCurrency; string selectedBTCToSellTextValue = SelectedBTCToSell().Text; string feeCurrency = TestData.GetData("CurrencyName"); Double selectedBTCToSellDoubleValue = Double.Parse(selectedBTCToSellTextValue);//BTCTOSell amount without any tag string selectedBTCToSellStringValue = GenericUtils.ConvertToDoubleFormat(selectedBTCToSellDoubleValue); string feeValue = GenericUtils.SellFeeAmount(selectedBTCToSellStringValue, priceText, feeFactor);//Fee amount without any tag(USD fee) string feeValues = feeValue + " " + USDCurrency; Thread.Sleep(1000); if (transactionOverviewDetails["TransactionCost"].Contains(selected100DollarPriceValue) && transactionOverviewDetails["BTCToSell"].Contains(selectedBTCToSellStringValue) && transactionOverviewDetails["Fee"].Contains(feeValues)) { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsPassed, side)); UserSetFunctions.Click(SellBitcoinWithUSDButton()); } else { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsFailed, side)); } string placeOrderTime = GenericUtils.GetCurrentTime(); string placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute(); string limitPriceOnConfirmationOrderValue = GenericUtils.ConvertToDoubleFormat(selected100DollarDoublePrice) + " " + USDCurrency; string feeOnConfirmationOrderValue = USDCurrency + " " + feeValue; string btcToSellAmount = BtcToSellValueOnConfirmOrder().Text; var finalQtyConfirmationOrderValues = selected100DollarDoublePrice - double.Parse(feeValue); Thread.Sleep(1000); var finalQtyConfirmationOrderValue = USDCurrency + " " + GenericUtils.ConvertTo8DigitAfterDecimal(finalQtyConfirmationOrderValues); Thread.Sleep(2000); var sellConfirmationDetails = GetSellConfirmationOverView(); if (sellConfirmationDetails["BTCToSell"].Contains(btcToSellAmount) && sellConfirmationDetails["LimitPrice"].Contains(limitPriceOnConfirmationOrderValue) && sellConfirmationDetails["Fee"].Contains(feeOnConfirmationOrderValue) && sellConfirmationDetails["FinalQantity"].Contains(finalQtyConfirmationOrderValue) && (sellConfirmationDetails["Date"].Contains(placeOrderTime) || sellConfirmationDetails["Date"].Contains(placeOrderTimePlusOneMin))) { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsPassed, side)); } else { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsFailed, side)); } UserSetFunctions.Click(ConfirmSellOrderButton()); string orderPlacedSuccessMsg = SuccessMsg().Text; try { Assert.Equal(orderPlacedSuccessMsg, Const.SuccessBuySellOrderMsg); logger.LogCheckPoint(String.Format(LogMessage.VerifiedBuySellOrderSuccessMsg, side)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.VerifiedBuySellOrderFailedMsg, side)); } Thread.Sleep(1000); UserSetFunctions.Click(OKSellButton()); Thread.Sleep(1000); UserSetFunctions.Click(BuyAndSellMenuButton()); Thread.Sleep(1000); UserCommonFunctions.SelectAnExchange(driver); Thread.Sleep(1000); UserCommonFunctions.ScrollingDownVertical(driver); Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTabForBuyAndSell(instrument, side, Double.Parse(selectedBTCToSellStringValue), feeValue, placeOrderTime, placeOrderTimePlusOneMin)); Thread.Sleep(1000); UserCommonFunctions.DashBoardMenuButton(driver); Thread.Sleep(1000); UserSetFunctions.Click(BuyAndSellButton()); Thread.Sleep(1000); string btcQty = GetSellBitcoinQuantity(bTCBalanceInDoubleValue, selectedBTCToSellDoubleValue); string usdBal = "$" + GetSellUSDBalances(usdBalance, feeValue); Thread.Sleep(1000); string currentbTCQuantity = BTCBalances().Text; string finalbTCQuantity = GenericUtils.RemoveCommaFromString(currentbTCQuantity); string currentUSDBalance = USDBalances().Text; string finalUSDBalance = GenericUtils.RemoveCommaFromString(currentUSDBalance); string usdDeductionAmount = TestData.GetData("TC42_USDDeductionAmount"); try { Assert.Equal(finalbTCQuantity, btcQty); logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityPassed, side)); } catch (Exception e) { logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityPassed, side)); throw e; } try { Assert.Equal(finalUSDBalance, usdBal); logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalancePassed, side, usdDeductionAmount)); } catch (Exception e) { logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalanceFailed, side, usdDeductionAmount)); throw e; } }
// This method place an sell order in BuyAndSell page public void PlaceSellOrder(string instrument, string side) { string bTCBalanceTextValue; string feeFactor; string actualBTCBalance; string usdBalanceTextValue; string usdBalance; string USDCurrency; string selected100DollarTextValue; string selected100DollarPrice; Double selected100DollarDoublePrice; Double selectedBTCToSellDoubleValue; string selected100DollarPriceValue; string selectedBTCToSellTextValue; string feeCurrency; string selectedBTCToSellStringValue; string feeValue; string feeValues; string orderPlacedSuccessMsg; string placeOrderTime; string placeOrderTimePlusOneMin; string limitPriceOnConfirmationOrderValue; string feeOnConfirmationOrderValue; string btcToSellAmount; string btcQty; string usdBal; string currentbTCQuantity; string finalbTCQuantity; string currentUSDBalance; string finalUSDBalance; string usdDeductionAmount; VerifyOrdersTab objVerifyOrdersTab = new VerifyOrdersTab(driver, logger); try { // Get BTC balance from Balances section on UI and convert into Double format bTCBalanceTextValue = BTCBalances().Text; feeFactor = TestData.GetData("FeeComponent"); Double bTCBalanceInDoubleValue = Double.Parse(bTCBalanceTextValue); actualBTCBalance = GenericUtils.ConvertToDoubleFormat(bTCBalanceInDoubleValue); // Get USD balance from Balances section on UI and convert into Double format usdBalanceTextValue = USDBalances().Text; usdBalance = usdBalanceTextValue.Split(Const.AddDollarSign)[1]; Thread.Sleep(1000); // This method will click on first radio button having option - $100 RadioBtn(); Thread.Sleep(1000); // Store all the details present in TransactionOverView Section var transactionOverviewDetails = GetSellTransactionOverView(); // Get price text from transactionOverviewDetails and split based on white space var priceText = transactionOverviewDetails["Price"].Split(Const.AddWhiteSpace)[0]; // Gets "USD" as string to append with currency value for comparison USDCurrency = TestData.GetData("USDCurrency"); // Get 100DollarTextValue from Amount section on UI and convert into Double format selected100DollarTextValue = selected100USD().Text; selected100DollarPrice = selected100DollarTextValue.Split(Const.AddDollarSign)[1]; selected100DollarDoublePrice = Double.Parse(selected100DollarPrice); selected100DollarPriceValue = GenericUtils.ConvertToDoubleFormat(selected100DollarDoublePrice) + Const.AddWhiteSpace + USDCurrency; // Get BTCToSellTextValue from Amount section on UI and convert into Double format selectedBTCToSellTextValue = SelectedBTCToSell().Text; feeCurrency = TestData.GetData("CurrencyName"); selectedBTCToSellDoubleValue = Double.Parse(selectedBTCToSellTextValue); selectedBTCToSellStringValue = GenericUtils.ConvertToDoubleFormat(selectedBTCToSellDoubleValue); // Get calcualted fee feeValue = GenericUtils.SellFeeAmount(selectedBTCToSellStringValue, priceText, feeFactor); feeValues = feeValue + Const.AddWhiteSpace + USDCurrency; Thread.Sleep(1000); // This will verify the details of "TransactionCost", "BTCToSell" and "Fee" components in Buy&Sell page if (transactionOverviewDetails["TransactionCost"].Contains(selected100DollarPriceValue) && transactionOverviewDetails["BTCToSell"].Contains(selectedBTCToSellStringValue) && transactionOverviewDetails["Fee"].Contains(feeValues)) { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsPassed, side)); UserSetFunctions.Click(SellBitcoinWithUSDButton()); } else { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsFailed, side)); } placeOrderTime = GenericUtils.GetCurrentTime(); placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute(); limitPriceOnConfirmationOrderValue = GenericUtils.ConvertToDoubleFormat(selected100DollarDoublePrice) + Const.AddWhiteSpace + USDCurrency; feeOnConfirmationOrderValue = USDCurrency + Const.AddWhiteSpace + feeValue; btcToSellAmount = BtcToSellValueOnConfirmOrder().Text; // Calculated Sell BTC amount var finalQtyConfirmationOrderValues = selected100DollarDoublePrice - double.Parse(feeValue); Thread.Sleep(1000); // Calculated buy USD amount var finalQtyConfirmationOrderValue = USDCurrency + Const.AddWhiteSpace + GenericUtils.ConvertTo8DigitAfterDecimal(finalQtyConfirmationOrderValues); Thread.Sleep(2000); // Store all the details present in TransactionOverView Section var sellConfirmationDetails = GetSellConfirmationOverView(); // This will verify the details of "BTCToSell", "LimitPrice", "Fee", "FinalQantity" and "Date" in the confirmation window if (sellConfirmationDetails["BTCToSell"].Contains(btcToSellAmount) && sellConfirmationDetails["LimitPrice"].Contains(limitPriceOnConfirmationOrderValue) && sellConfirmationDetails["Fee"].Contains(feeOnConfirmationOrderValue) && sellConfirmationDetails["FinalQantity"].Contains(finalQtyConfirmationOrderValue) && (sellConfirmationDetails["Date"].Contains(placeOrderTime) || sellConfirmationDetails["Date"].Contains(placeOrderTimePlusOneMin))) { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsPassed, side)); } else { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsFailed, side)); } //Click on "Confirm Sell Order" button UserSetFunctions.Click(ConfirmSellOrderButton()); orderPlacedSuccessMsg = SuccessMsg().Text; // This will verify the success message of placed sell order try { Assert.Equal(orderPlacedSuccessMsg, Const.SuccessBuySellOrderMsg); logger.LogCheckPoint(String.Format(LogMessage.BuySellOrderPassedMsg, side)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.BuySellOrderFailedMsg, side)); } Thread.Sleep(3000); // Click on "OK" button UserSetFunctions.Click(OKSellButton()); Thread.Sleep(1000); // Click on "Buy&Sell" menu button --> exchange button--> scroll down to filled order tab UserSetFunctions.Click(BuyAndSellMenuButton()); Thread.Sleep(1000); UserCommonFunctions.SelectAnExchange(driver); Thread.Sleep(1000); UserCommonFunctions.ScrollingDownVertical(driver); // This will verify filled orders tab after placing successfull sell order Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTabForBuyAndSell(instrument, side, Double.Parse(selectedBTCToSellStringValue), feeValue, placeOrderTime, placeOrderTimePlusOneMin)); Thread.Sleep(1000); UserCommonFunctions.DashBoardMenuButton(driver); Thread.Sleep(1000); UserSetFunctions.Click(BuyAndSellButton()); Thread.Sleep(1000); // Get the final sell quantity amount(btcBalance-btcToSellAmount) btcQty = GetSellBitcoinQuantity(bTCBalanceInDoubleValue, selectedBTCToSellDoubleValue); usdBal = Const.AddDollarSign + GetSellUSDBalances(usdBalance, feeValue); Thread.Sleep(1000); // BTC balance from the Balances section post transaction currentbTCQuantity = BTCBalances().Text; finalbTCQuantity = GenericUtils.RemoveCommaFromString(currentbTCQuantity); // USD balance from the Balances section post transaction currentUSDBalance = USDBalances().Text; finalUSDBalance = GenericUtils.RemoveCommaFromString(currentUSDBalance); usdDeductionAmount = TestData.GetData("TC42_USDDeductionAmount"); // This will verify the value of final btc quantity try { Assert.Equal(finalbTCQuantity, btcQty); logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityPassed, side)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityFailed, side)); throw; } // This will verify the value of final USD balance try { Assert.Equal(finalUSDBalance, usdBal); logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalancePassed, side, usdDeductionAmount)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalanceFailed, side, usdDeductionAmount)); throw; } } catch (Exception) { throw; } }
// This will place an buy order in BuyAndSell page public void PlaceBuyOrder(string instrument, string side) { VerifyOrdersTab objVerifyOrdersTab = new VerifyOrdersTab(driver, logger); try { // Get BTC balance from Balances section on UI and convert into Double format string bTCBalanceTextValue = BTCBalances().Text; Double bTCBalanceInDoubleValue = Double.Parse(bTCBalanceTextValue); string actualBTCBalance = GenericUtils.ConvertToDoubleFormat(bTCBalanceInDoubleValue); // Get USD balance from Balances section on UI and convert into Double format string usdBalanceTextValue = USDBalances().Text; string usdBalance = usdBalanceTextValue.Split(Const.AddDollarSign)[1]; Thread.Sleep(1000); // This method will click on first radio button having option - $100 RadioBtn(); Thread.Sleep(1000); // Store all the details present in TransactionOverView Section var transactionOverviewDetails = GetBuyTransactionOverView(); // Get price text from transactionOverviewDetails and split based on white space var priceText = transactionOverviewDetails["Price"].Split(Const.AddWhiteSpace)[0]; // Gets "USD" as string to append with currency value for comparison string USDCurrency = TestData.GetData("USDCurrency"); // Get 100DollarTextValue from Amount section on UI and convert into Double format string selected100DollarTextValue = selected100USD().Text; string selected100DollarPrice = selected100DollarTextValue.Split(Const.AddDollarSign)[1]; Double selected100DollarDoublePrice = Double.Parse(selected100DollarPrice); string selected100DollarPriceValue = GenericUtils.ConvertToDoubleFormat(selected100DollarDoublePrice) + Const.AddWhiteSpace + USDCurrency; // Get BTCToBuyTextValue from Amount section on UI and convert into Double format string selectedBTCToBuyTextValue = SelectedBTCToBuy().Text; string feeCurrency = TestData.GetData("CurrencyName"); Double selectedBTCToBuyDoubleValue = Double.Parse(selectedBTCToBuyTextValue); string selectedBTCToBuyStringValue = GenericUtils.ConvertToDoubleFormat(selectedBTCToBuyDoubleValue); string feeValue = CalculateFee(selectedBTCToBuyStringValue); string feeValues = feeValue + Const.AddWhiteSpace + feeCurrency; Thread.Sleep(1000); // This will verify the details of "TransactionCost", "BTCToBuy" and "Fee" components in Buy&Sell page if (transactionOverviewDetails["TransactionCost"].Contains(selected100DollarPriceValue) && transactionOverviewDetails["BTCToBuy"].Contains(selectedBTCToBuyStringValue) && transactionOverviewDetails["Fee"].Contains(feeValues)) { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsPassed, side)); UserSetFunctions.Click(BuyBitcoinWithUSDButton()); } else { logger.LogCheckPoint(String.Format(LogMessage.TransactionOverviewDetailsFailed, side)); } string placeOrderTime = GenericUtils.GetCurrentTime(); string placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute(); // This gets the limit Price On Confirmation Order Value string limitPriceOnConfirmationOrderValue = GenericUtils.ConvertDoubleToString(selected100DollarDoublePrice) + Const.AddWhiteSpace + USDCurrency; string feeOnConfirmationOrderValue = feeCurrency + Const.AddWhiteSpace + feeValue; // Get the final quantity amount(btcToBuyAmount-feeValue) string finalQtyDiff = GenericUtils.GetDifferenceFromStringAfterSubstraction(selectedBTCToBuyTextValue, feeValue); var finalQtyConfirmationOrderValues = feeCurrency + Const.AddWhiteSpace + Decimal.Parse(finalQtyDiff).ToString("0.00"); Thread.Sleep(2000); var buyConfirmationDetails = GetBuyConfirmationOverView(); // This will verify the details of "BTCToBuy", "LimitPrice", "Fee", "FinalQantity" and "Date" in the confirmation window if (buyConfirmationDetails["BTCToBuy"].Contains(selectedBTCToBuyTextValue) && buyConfirmationDetails["LimitPrice"].Contains(selected100DollarPriceValue) && buyConfirmationDetails["Fee"].Contains(feeOnConfirmationOrderValue) && buyConfirmationDetails["FinalQantity"].Contains(finalQtyConfirmationOrderValues) && (buyConfirmationDetails["Date"].Contains(placeOrderTime) || buyConfirmationDetails["Date"].Contains(placeOrderTimePlusOneMin))) { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsPassed, side)); } else { logger.LogCheckPoint(String.Format(LogMessage.ConfirmationModalDetailsFailed, side)); } // Click on "Confirm Buy Order" button UserSetFunctions.Click(ConfirmBuyOrderButton()); string orderPlacedSuccessMsg = SuccessMsg().Text; // This will verify the success message of placed buy order try { Assert.Equal(orderPlacedSuccessMsg, Const.SuccessBuySellOrderMsg); logger.LogCheckPoint(String.Format(LogMessage.BuySellOrderPassedMsg, side)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.BuySellOrderFailedMsg, side)); } Thread.Sleep(1000); for (int i = 0; i <= 2; i++) { try { // Click on "OK" button UserSetFunctions.Click(OKBuyButton()); break; } catch (StaleElementReferenceException) { } } for (int i = 0; i <= 2; i++) { try { UserSetFunctions.Click(BuyAndSellMenuButton()); break; } catch (StaleElementReferenceException) { } } // Click on exchange Menu button UserCommonFunctions.SelectAnExchange(driver); //Scroll down to the Filled order tabs UserCommonFunctions.ScrollingDownVertical(driver); // verify the order placed in Filled orders tab through Order Entry Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTabForBuyAndSell(instrument, side, Double.Parse(selectedBTCToBuyStringValue), feeValue, placeOrderTime, placeOrderTimePlusOneMin)); Thread.Sleep(1000); //Click on Dashboard menu button --> Buy&Sell menu button UserCommonFunctions.DashBoardMenuButton(driver); Thread.Sleep(1000); UserSetFunctions.Click(BuyAndSellButton()); Thread.Sleep(1000); // Calculate the buy BTC amount string btcQty = GetBuyBitcoinQuantity(bTCBalanceInDoubleValue, selectedBTCToBuyDoubleValue, feeValue); // Calculate the buy USD amount string usdBal = Const.AddDollarSign + GetBuyUSDBalances(usdBalance); Thread.Sleep(1000); // BTC balance from the Balances section post transaction string currentbTCQuantity = BTCBalances().Text; string finalbTCQuantity = GenericUtils.RemoveCommaFromString(currentbTCQuantity); // USD balance from the Balances section post transaction string currentUSDBalance = USDBalances().Text; string finalUSDBalance = GenericUtils.RemoveCommaFromString(currentUSDBalance); string usdDeductionAmount = TestData.GetData("TC42_USDDeductionAmount"); // This will verify the value of final btc amount with the caluclated amount try { Assert.Equal(finalbTCQuantity, btcQty); logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityPassed, side)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.FinalBTCQantityPassed, side)); throw; } // This will verify the value of final USD balance with the caluclated amount try { Assert.Equal(finalUSDBalance, usdBal); logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalancePassed, side, usdDeductionAmount)); } catch (Exception) { logger.LogCheckPoint(String.Format(LogMessage.FinalUSDBalanceFailed, side, usdDeductionAmount)); throw; } } catch (Exception) { throw; } }
//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; } }