//Obtains Username and Password data for both banks private void obtainUserData() { readData.currentSheet = 1; readData.InitializeExcel(userDataPath); //readData.obtainExcelDataTest(); //Obtain NET Data NET_data NET_UserInfo = new NET_data(); readData.obtainDataNET(NET_UserInfo); NET_User = NET_UserInfo.User; NET_Pass = NET_UserInfo.Pass; //Obtain DCU Data DCU_data DCU_UserInfo = new DCU_data(); readData.obtainDataDCU(DCU_UserInfo); DCU_User = DCU_UserInfo.User; DCU_Pass = DCU_UserInfo.Pass; //Obtain Email Sender Data MailSender_data MailSender_UserInfo = new MailSender_data(); readData.obtainSendEmailData(MailSender_UserInfo); senderEmailAddress = MailSender_UserInfo.senderMailAddress; senderEmailPassword = MailSender_UserInfo.senderMailPassword; //Cleanup excel app readData.Cleanup(); }
public static void writeTransactionsToExcelNET(NET_data transactions) { try { lastRow += 1; MySheet.Cells[lastRow, 1] = transactions.Date; MySheet.Cells[lastRow, 2] = transactions.Description; MySheet.Cells[lastRow, 3] = transactions.Amount; MySheet.Cells[lastRow, 4] = transactions.Balance; //NETDataList.Add(transactions); } catch (Exception) { } //MyBook.Close(); //MyApp.Quit(); }
public static void writeAccountsToExcelNET(NET_data accounts) { MySheet.Cells[3, 2] = accounts.Checking; MySheet.Cells[4, 2] = accounts.Savings; }
public void obtainDataNET(NET_data UserInfo) { UserInfo.User = Sheet.Cells[2, 2].value(); UserInfo.Pass = Sheet.Cells[3, 2].value(); }
//NET Federal Credit Union Login private void NETlogin() { //NET Federal Bank Login //Run selenium FirefoxDriver fd = new FirefoxDriver(); fd.Url = @"https://netfedcu.online-cu.com/ISuite5/Features/Auth/MFA/Default.aspx"; fd.Navigate(); IWebElement r = fd.FindElementById("ctl01_Main1_UserIDTextbox"); r.SendKeys(NET_User); r = fd.FindElementById("ctl01_Main1_LoginBtn"); r.Click(); new WebDriverWait(fd, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.Id("ctl01_Main1_PasswordTextbox")))); r = fd.FindElementById("ctl01_Main1_PasswordTextbox"); r.SendKeys(NET_Pass); r = fd.FindElementById("ctl01_Main1_SignInBtn"); r.Click(); //Get Data for Checking new WebDriverWait(fd, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.Id("ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl03_AvailBalLabel")))); r = fd.FindElementById("ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl03_AvailBalLabel"); lblNetCheckingData.Text = r.GetAttribute("innerHTML"); //Get Data for Savings new WebDriverWait(fd, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.Id("ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl02_AvailBalLnkBtn")))); r = fd.FindElementById("ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl02_AvailBalLnkBtn"); lblNetSavingsData.Text = r.GetAttribute("innerHTML"); //Store accounts data in NET_data NET_data accounts = new NET_data() { Checking = lblNetCheckingData.Text, Savings = lblNetSavingsData.Text, }; //Write Checking and Savings to excel file WriteToExcel.writeAccountsToExcelNET(accounts); //Change Sheet to NET checking startExcel.currentSheet = 5; //navigate to checking table //r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl03_ACSLabelLnkBtn']")); r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_MemberTab_objc0_ctl00_AccountSummaryLiteGrid_ctl03_RecentActivityLnkBtn']")); r.Click(); System.Threading.Thread.Sleep(10000); //Select show last 28 days in history combo box IWebElement iWebelement = fd.FindElement(By.Id("ctl01_Main1_dropdownDateRange")); //Getting the element of the Text Box IWebElement iWebelementList = fd.FindElement(By.Id("ctl01_Main1_dropdownDateRange")); //Getting the elements of List/Drop down Box SelectElement selected = new SelectElement(iWebelementList); //Parsing the list iWebelement.SendKeys(OpenQA.Selenium.Keys.ArrowDown); // Clicking the drop down image selected.SelectByText("Last 28 Days"); // Use select element class to select the value //click show history button r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_UISButtonShowHistory']")); r.Click(); System.Threading.Thread.Sleep(10000); //Check for number of rows to obtain data from for (int x = 2; x < 1000;) { // Store detected elements in a data list List <IWebElement> elementList = new List <IWebElement>(); elementList.AddRange(fd.FindElements(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid']/tbody/tr[" + x + "]/td[1]"))); if (elementList.Count > 0) { x++; lbltest.Text = x.ToString(); } else { break; } } //Convert element count to an integer. Decrease by 2 for accuracy when looping. int checkEleCount = Convert.ToInt32(lbltest.Text); checkEleCount = checkEleCount - 2; //change to checking excel sheet currentSheet = 5; startExcel.ChangeSheet(currentSheet); //Add data for each transaction for (int x = 1; x <= checkEleCount;) { Label[] activeLabel = { lblNetDateRes, lblNetDesRes, lblNetAmtRes, lblWithRes }; // Default strings. Changes after assigned new value. string activeNetDate = "No good Date"; string activeNetDes = "No good Des"; string activeNetAmount = "No good Amt"; string activeNetBalance = "No good Bal"; string[] currentElement = { activeNetDate, activeNetDes, activeNetAmount, activeNetBalance }; //assign values to labels for each part of the transaction in the selected row { r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid']/tbody/tr[" + (x + 1) + "]/td[1]")); activeLabel[0].Text = r.GetAttribute("innerHTML"); currentElement[0] = activeLabel[0].Text; if (x < 9) { r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid_ctl0" + (x + 1) + "_UneditedDescription']")); } else { r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid_ctl" + (x + 1) + "_UneditedDescription']")); } activeLabel[1].Text = r.GetAttribute("innerHTML"); currentElement[1] = activeLabel[1].Text; r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid']/ tbody/tr[" + (x + 1) + "]/td[3]")); activeLabel[2].Text = r.GetAttribute("innerHTML"); currentElement[2] = activeLabel[2].Text; r = fd.FindElement(By.XPath(".//*[@id='ctl01_Main1_SufixListRepeater_ctl03_HistoryForRepeatSuffix1_SFXHistoryRollup_SFXHistoryGrid']/ tbody/tr[" + (x + 1) + "]/td[4]")); activeLabel[3].Text = r.GetAttribute("innerHTML"); currentElement[3] = activeLabel[3].Text; } NET_data transactions = new NET_data { Date = currentElement[0], Description = currentElement[1], Amount = currentElement[2], Balance = currentElement[3], }; //Write transactions to excel WriteToExcel.writeTransactionsToExcelNET(transactions); x++; } fd.Navigate().Back(); //Log out of NET Bank new WebDriverWait(fd, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.Id("ctl01_LogoutImage")))); r = fd.FindElementById("ctl01_LogoutImage"); r.Click(); //Send data from labels to NET_data for main Accounts //MyExcel netExcel = new MyExcel(); ////Open excel and set accounts excel sheet //netExcel.currentSheet = 2; //netExcel.InitializeExcel(excelPath + templateName); System.Threading.Thread.Sleep(10000); new WebDriverWait(fd, TimeSpan.FromSeconds(120)); fd.Close(); System.Threading.Thread.Sleep(10000); fd.Quit(); }