// Handles Trades in Block 1 public void Block1(int row, int sheetNum) { System.Diagnostics.Debug.WriteLine("CHECKING FOR TRADE TYPE QUESTIONS, DATA SET: BLOCK 1"); // primary question for this trade block string data_A = excelFileReader.ExcelLookup(24, row, sheetNum); string element_A = "//input[contains(@class, 'element_a_classname') and contains(@value, '" + data_A + "')]/parent::label"; WebdriverOperations(element_A, 1, data_A); if (data_A == yes) { // How many x peform y? string data_b = excelFileReader.ExcelLookup(25, row, sheetNum); string element_b = "//select[contains(@class, 'element_b_classname')]/option[contains(text(), '" + data_b + "')]"; WebdriverOperations(element_b, 1, data_b); // how many xa perform yx? string data_c = excelFileReader.ExcelLookup(26, row, sheetNum); string element_c = "//input[contains(@class, 'element_c_classname') and contains(@value, '" + data_c + "')]/parent::label"; WebdriverOperations(element_c, 1, data_c); if (data_c == yes) { // sub question string data_d = excelFileReader.ExcelLookup(27, row, sheetNum); string element_d = "//input[contains(@class, 'element_d_classname')]"; WebdriverOperations(element_d, 2, data_d); } } }
// User Details public void UserDetailsInput(int row, int sheetNum) { // Redacted and adjusted for public repo System.Diagnostics.Debug.WriteLine("INSERTING USER DETAILS\n"); WaitForPageLoad(); // Contact Name string checkForContactName = excelFileReader.ExcelLookup(2, row, sheetNum); string contactName = "ContactName"; WebdriverOperations(contactName, 4, checkForContactName); // Email string checkForEmail = excelFileReader.ExcelLookup(3, row, sheetNum); string email = "Email"; WebdriverOperations(email, 4, checkForEmail); // Company Name string checkForCompanyName = excelFileReader.ExcelLookup(4, row, sheetNum); string companyName = "CompanyName"; WebdriverOperations(companyName, 4, checkForCompanyName); // Mobile Number string checkForMobileNumber = excelFileReader.ExcelLookup(5, row, sheetNum); string mobileNumber = "Mobile"; WebdriverOperations(mobileNumber, 4, checkForMobileNumber); // Submit 1st Form string submitBtn = "//*[@id='quoteForm']/div[6]/div[2]/button"; WebdriverOperations(submitBtn, 1); WaitForPageLoad(); //// Corresponde Address (POSTCODE) string checkPostcode = excelFileReader.ExcelLookup(6, row, sheetNum); string ps = "Postcode"; WebdriverOperations(ps, 4, checkPostcode); }
// Method can be invoked // Created for contact-form input public void InsertData(int row) { string firstName = excel.ExcelLookup(1, row, 1); string firstNameElementLocator = "//input[contains(@class, 'firstname') and contains(@placeholder, 'Your name..')]"; WaitForElementAndSendKeys(firstNameElementLocator, firstName); string lastName = excel.ExcelLookup(2, row, 1); string lastNameElementLocator = "//input[contains(@id, 'lname') and contains(@placeholder, 'Your last name..')]"; WaitForElementAndSendKeys(lastNameElementLocator, lastName); string country = excel.ExcelLookup(3, row, 1); string countryLocator = "//input[contains(@name, 'country') and contains(@placeholder, 'Enter your Country')]"; WaitForElementAndSendKeys(countryLocator, country); string subject = excel.ExcelLookup(4, row, 1); string subjectLocator = "//textarea[contains(@id, 'subject') and contains(@placeholder, 'Write something')]"; WaitForElementAndSendKeys(subjectLocator, subject); }
// Storing list of trades into new lists that will be operated on // Then checking whether clients main or secondary trade matches a certain trade found inside the strings (checkTradeBlock) // If a match is found, then the input/methods corresponding to the found trade type are run (Block) public void FilterTradeQuestions(int row, int sheetNum) { // Redacted & Adjusted for Public Repo if (sheetNum == 1) { string ClientMainTrade = excelFileReader.ExcelLookup(10, row, sheetNum); string ClientSecondTrade = excelFileReader.ExcelLookup(12, row, sheetNum); List <String> checkTradeBlock1 = ListOfTrades.TradeBlock1; if (checkTradeBlock1.Where(x => checkTradeBlock1.Contains(ClientMainTrade) || checkTradeBlock1.Contains(ClientSecondTrade)).Any()) { Block1(row, sheetNum); } List <String> checkTradeBlock2 = ListOfTrades.TradeBlock2; if (checkTradeBlock2.Where(x => checkTradeBlock2.Contains(ClientMainTrade) || checkTradeBlock2.Contains(ClientSecondTrade)).Any()) { Block2(row, sheetNum); } List <String> checkTradeBlock3 = ListOfTrades.TradeBlock3; if (checkTradeBlock3.Where(x => checkTradeBlock3.Contains(ClientMainTrade) || checkTradeBlock3.Contains(ClientSecondTrade)).Any()) { Block3(row, sheetNum); } List <String> checkTradeBlock4 = ListOfTrades.TradeBlock4; if (checkTradeBlock4.Where(x => checkTradeBlock4.Contains(ClientMainTrade) || checkTradeBlock4.Contains(ClientSecondTrade)).Any()) { Block4(row, sheetNum); } List <String> checkTradeBlock5 = ListOfTrades.TradeBlock5; if (checkTradeBlock5.Where(x => checkTradeBlock5.Contains(ClientMainTrade) || checkTradeBlock5.Contains(ClientSecondTrade)).Any()) { Block5(row, sheetNum); } } if (sheetNum == 2 || sheetNum == 3) { //Web Form 2 string clientMainTrade = excelFileReader.ExcelLookup(10, row, sheetNum); List <string> checkTradeBlock6 = ListOfTrades.TradeBlock6; if (checkTradeBlock6.Where(x => checkTradeBlock6.Contains(clientMainTrade)).Any()) { Block6(row, sheetNum); } List <string> checkTradeBlock7 = ListOfTrades.TradeBlock7; if (checkTradeBlock7.Where(x => checkTradeBlock7.Contains(clientMainTrade)).Any()) { Block7(row, sheetNum); } List <string> checkTradeBlock8 = ListOfTrades.TradeBlock8; if (checkTradeBlock8.Where(x => checkTradeBlock8.Contains(clientMainTrade)).Any()) { Block8(row, sheetNum); } List <string> checkTradeBlock9 = ListOfTrades.TradeBlock9; if (checkTradeBlock9.Where(x => checkTradeBlock9.Contains(clientMainTrade)).Any()) { Block9(row, sheetNum); } string checkTradeBlock10 = ListOfTrades.TradeBlock10; if (checkTradeBlock10 == clientMainTrade) { Block10(row, sheetNum); } string checkTradeBlock11 = ListOfTrades.TradeBlock11; if (checkTradeBlock11 == clientMainTrade) { Block11(row, sheetNum); } List <string> checkTradeBlock12 = ListOfTrades.TradeBlock12; if (checkTradeBlock12.Where(x => checkTradeBlock12.Contains(clientMainTrade)).Any()) { Block12(row, sheetNum); } List <string> checkTradeBlock13 = ListOfTrades.TradeBlock13; if (checkTradeBlock13.Where(x => checkTradeBlock13.Contains(clientMainTrade)).Any()) { Block13(row, sheetNum); } List <string> checkTradeBlock14 = ListOfTrades.TradeBlock14; if (checkTradeBlock14.Where(x => checkTradeBlock14.Contains(clientMainTrade)).Any()) { Block14(row, sheetNum); } string checkTradeBlock15 = ListOfTrades.TradeBlock15; if (checkTradeBlock15 == clientMainTrade) { Block15(row, sheetNum); } string checkTradeBlock16 = ListOfTrades.TradeBlock16; if (checkTradeBlock16 == clientMainTrade) { Block16(row, sheetNum); } List <string> checkTradeBlock17 = ListOfTrades.TradeBlock17; if (checkTradeBlock17.Where(x => checkTradeBlock17.Contains(clientMainTrade)).Any()) { Block17(row, sheetNum); } } }