using UI2023.BaseClasses;
using UI2023.ComponentHelper;
using UI2023.PageObjects;
using UI2023.ParamObjectDTO;
using UI2023.Settings;
using UI2023.Utilities;
using ExcelDataReader;
using NUnit.Framework;
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Threading;
/*using static System.Runtime.InteropServices.JavaScript.JSType;
using TechTalk.SpecFlow;*/
namespace UI2023.Testcases
{
[TestFixture]
public class Login_Logout : BaseClass
{
private ThreadLocal<IWebDriver> driver = new ThreadLocal<IWebDriver>();
private LoginPage loginPage;
[SetUp]
public void Intiallize()
{
driver.Value = InitWebdriver();
ExtentTestManager.CreateTest("LoginValidation");
// BrowserHelper.NavigateToUrl(".../ClientLogin.aspx", driver.Value);
ReportLog.Pass("Successfully Navigated to Login Page");
loginPage = ObjectRepository.LoginPage(driver.Value);
}
[Test]
[Category("Regression")]
[TestCaseSource(nameof(AddBankAccountsData))]
public void Fxecute_PSR_Flow(CreateTransactionDTO data)
{
Console.WriteLine(data.buyAmount);
try
{
loginPage.LoginToFX("sfl", "gayathrisfl", "Test@1234");
if (loginPage.isNewDeviceLoginDetected())
{
loginPage.newdeviceokbtn.Click();
}
loginPage.clickOnTransactionTab();
//string FID=loginPage.CreateTask("BRL - BRAZILIAN REAL", "USD - UNITED STATES DOLLAR", "1000", "BRL 01", "Test");
string FID = loginPage.CreateTask(data.buyCurrency, data.sellCurrency, data.buyAmount, data.deliveryinstruction, data.poptext);
BrowserHelper.NavigateToUrl(".......Login.aspx", driver.Value);
loginPage.LoginToFXhost("gayathri.jayaram", "Blackmail@1234");
//string FID = Current["FID"];
loginPage.TradeTabClick("4403662");
}
catch (Exception ex)
{
ReportLog.Fail("Click base64-img button to see error screenshot \n", CaptureScreenshotAndReturnModel("screenshot", driver.Value));
ReportLog.Fail("Test Case Failed : Login and Logout is not successful -" + ex.Message);
throw;
}
}
/* public static IEnumerable<CreateTransactionDTO> AddCreateTaskData()
{
// Path to the Excel file
string workingDirectory = Environment.CurrentDirectory;
string filePath = Directory.GetParent(workingDirectory).Parent.Parent.FullName + "\\Utilities\\Testdata.xlsx";
string sheetName = "CreateTrade"; // Name of the sheet containing the test data
// Load the Excel file
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
// Read the test data from the specified sheet
DataSet dataSet = reader.AsDataSet();
DataTable dataTable = dataSet.Tables[sheetName];
bool isFirstRow = true;
List<CreateTransactionDTO> CreateTaskData = new List<CreateTransactionDTO>();
// Iterate through the rows of the table and create DTO objects
foreach (DataRow row in dataTable.Rows)
{
if (isFirstRow)
{
isFirstRow = false;
continue;
}
CreateTransactionDTO paymentData = new CreateTransactionDTO
{
buyCurrency = row[0].ToString(),
sellCurrency = row[1].ToString(),
buyAmount = row[2].ToString(),
sellAmount = row[3].ToString(),
deliveryinstruction = row[4].ToString(),
poptext = row[5].ToString(),
};
CreateTaskData.Add(paymentData);
}
return CreateTaskData;
}
}
}*/
public static IEnumerable<CreateTransactionDTO> AddBankAccountsData()
{
// Path to the Excel file
string workingDirectory = Environment.CurrentDirectory;
string filePath = Directory.GetParent(workingDirectory).Parent.Parent.FullName + "\\Utilities\\Testdata.xlsx";
string sheetName = "CreateTrade"; // Name of the sheet containing the test data
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
// Load the Excel file
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
// Read the test data from the specified sheet
DataSet dataSet = reader.AsDataSet();
DataTable dataTable = dataSet.Tables[sheetName];
bool isFirstRow = true;
List<CreateTransactionDTO> createPaymentDataList = new List<CreateTransactionDTO>();
// Iterate through the rows of the table and create DTO objects
foreach (DataRow row in dataTable.Rows)
{
if (isFirstRow)
{
isFirstRow = false;
continue;
}
CreateTransactionDTO paymentData = new CreateTransactionDTO
{
buyCurrency = row[0].ToString(),
sellCurrency = row[1].ToString(),
buyAmount = row[2].ToString(),
sellAmount = row[3].ToString(),
deliveryinstruction = row[4].ToString(),
poptext = row[5].ToString()
};
createPaymentDataList.Add(paymentData);
}
return createPaymentDataList;
}
}
}
[TearDown]
public void Cleanup()
{
if (driver.Value != null)
{
driver.Value.Quit();
QuitDriverProcess();
}
}
}
}
x
Tuesday, January 9, 2024
simple Trade using excel
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment