//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; } }