//Enter Share Skill Data internal void EnterShareSkillData() { //Enter the Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Enter the Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select Category GlobalDefinitions.SelectDropDown(CategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select Sub-Category GlobalDefinitions.SelectDropDown(SubCategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + "\n"); //Select Service Type GlobalDefinitions.SelectRadioButton(ServiceTypeOptions, GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"), By.Name("serviceType")); //Select Location Type GlobalDefinitions.SelectRadioButton(LocationTypeOption, GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"), By.Name("locationType")); //Add Start Date StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Add End Date EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Select days and Enter start and End time EnterDaysAndTime(); //Select Skill Trade GlobalDefinitions.SelectRadioButton(SkillTradeOption, GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade"), By.Name("skillTrades")); string SkillTradeValue = GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade").ToUpper(); //Enter Skill-Exchange or Credit if (SkillTradeValue == "SKILL-EXCHANGE") { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + "\n"); } else { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //upload Work Samples WorkSamples.Click(); AutoItX.WinWait("Open", "File Upload", 1); AutoItX.WinActivate("Open"); AutoItX.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); AutoItX.Send(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\ExcelData\\empty.txt")); AutoItX.Send("{Enter}"); //Select Active radio GlobalDefinitions.SelectRadioButton(ActiveOption, GlobalDefinitions.ExcelLib.ReadData(2, "Active"), By.Name("isActive")); }
public void AddShareSkillDetails(ShareSkillDetails skillObj) { //Enter Title data from Excel driver.WaitForElementIsVisible(TitleTextBox); TitleTextBox.SendKeys(skillObj.Title); //Enter Description data from Excel DescriptionTextBox.SendKeys(skillObj.Description); //Select Category based on Excel data driver.WaitForElementIsVisible(CategoryDropDown); SelectElement categorySelect = new SelectElement(CategoryDropDown); categorySelect.SelectByText(skillObj.Category); //Select Subcategory based on Excel data SelectElement subCategorySelect = new SelectElement(SubCategoryDropDown); subCategorySelect.SelectByText(skillObj.SubCategory); //Enter Text in Tag and perform keyboard action "Enter" TagTextBox.SendKeys(skillObj.Tags + Keys.Enter); //Select Service Type based on Excel data SelectRadioButton(ServiceType, ServiceTypeLabel, skillObj.ServiceType); //Select Location Type based on Excel data SelectRadioButton(LocationType, LocationTypeLabel, skillObj.LocationType); //Enter Startdate based on Excel data StartDate.SendKeys(skillObj.StartDate); //Enter Enddate based on Excel data EndDate.SendKeys(skillObj.EndDate); //Select days based on excel data and enter start and end time SelectAvailableDays(skillObj.SelectDay, skillObj.StartTime, skillObj.EndTime); //Select SkillTrade based on Excel data SelectRadioButton(SkillTrade, SkillTradeLabel, skillObj.SkillTrade); //Enter Text in Tag and perform keyboard action "Enter" SkillExchange.SendKeys(skillObj.SkillExchange + Keys.Enter); //Click WorkSample and upload the file through AutoIT driver.WaitForElementIsVisible(WorkSamples); WorkSamples.Click(); UploadFileByAutoIT(); //Select Active/Hidden based on Excel data SelectRadioButton(Active, ActiveLabel, skillObj.Active); //Save ShareSkill data SaveButton.Click(); }
internal void EnterShareSkillData() { //Enter the Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Enter the Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select Category GlobalDefinitions.SelectDropDown(CategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select Sub-Category GlobalDefinitions.SelectDropDown(SubCategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + "\n"); //Select Service Type GlobalDefinitions.SelectRadioButton(ServiceTypeOptions, GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"), By.Name("serviceType")); //Select Location Type GlobalDefinitions.SelectRadioButton(LocationTypeOption, GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"), By.Name("locationType")); //Add Start Date StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Add End Date EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Getting all the values in Selectday column in a list IList <string> DaysList = GlobalDefinitions.ExcelLib.ReadData(2, "Selectday").Split('/'); //Getting count for all days //Check the checkbox for selectdays mentioned in excel and enter time for same int DaysRows = Days.FindElements(By.Name("Available")).Count; foreach (string AvailableDays in DaysList) { for (int i = 1; i <= DaysRows; i++) { string DayValue = Days.FindElements(By.ClassName("fields"))[i].Text; if (AvailableDays.ToLower() == DayValue.ToLower()) { Days.FindElements(By.Name("Available"))[i - 1].Click(); string StartTime = DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("hh:mmtt"); Days.FindElements(By.Name("StartTime"))[i - 1].SendKeys(StartTime); string EndTime = DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("hh:mmtt"); Days.FindElements(By.Name("EndTime"))[i - 1].SendKeys(EndTime); break; } } } //Select Skill Trade GlobalDefinitions.SelectRadioButton(SkillTradeOption, GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade"), By.Name("skillTrades")); string SkillTradeValue = GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade").ToUpper(); //Enter Skill-Exchange or Credit if (SkillTradeValue == "SKILL-EXCHANGE") { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + "\n"); } else { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //upload Work Samples WorkSamples.Click(); AutoItX.WinWait("Open", "File Upload", 1); AutoItX.WinActivate("Open"); AutoItX.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); AutoItX.Send(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\ExcelData\\empty.txt")); AutoItX.Send("{Enter}"); //Select Active radio GlobalDefinitions.SelectRadioButton(ActiveOption, GlobalDefinitions.ExcelLib.ReadData(2, "Active"), By.Name("isActive")); }
internal void EnterShareSkill() { //Calling wait method GenericWait.ElementExists(GlobalDefinitions.driver, "Name", "title", 8); //Entering the "Title" Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Validating Title GlobalDefinitions.TextDataFieldValidation("Title", GlobalDefinitions.ExcelLib.ReadData(2, "Title"), Title.GetAttribute("value")); //Entering the "Description" Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Validating Description GlobalDefinitions.TextDataFieldValidation("Description", GlobalDefinitions.ExcelLib.ReadData(2, "Description"), Description.Text); //Selecting Category HelperCallingMethods.SelectingDropdown(CategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Validating Category selection GlobalDefinitions.DropDownDataValidation("Category", CategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Selecting Sub-Category HelperCallingMethods.SelectingDropdown(SubCategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Validating Sub-Category selection GlobalDefinitions.DropDownDataValidation("SubCategory", SubCategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Entering Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + "\n"); //GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//span[@class='ReactTags__tag']"), 5); GenericWait.ElementIsVisible(GlobalDefinitions.driver, "XPath", "//span[@class='ReactTags__tag']", 6); string EnteredTagTxt = TagReact.Text; //Validating entered Tag GlobalDefinitions.TextDataFieldValidation("Tags", GlobalDefinitions.ExcelLib.ReadData(2, "Tags"), EnteredTagTxt.Remove(EnteredTagTxt.Length - 1, 1)); // Select the Service type radio button HelperCallingMethods.SelectingRadiobutton("//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", "serviceType", GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType")); //Validating Service Type Radiobutton selection GlobalDefinitions.RadiobuttonValidation("ServiceTypeRadioButtons", "//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", "serviceType", GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType")); // Select the Location type radio button HelperCallingMethods.SelectingRadiobutton("//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", "locationType", GlobalDefinitions.ExcelLib.ReadData(2, "LocationType")); //Validating Location Type Radiobutton selection GlobalDefinitions.RadiobuttonValidation("LocationTypeRadioButtons", "//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", "locationType", GlobalDefinitions.ExcelLib.ReadData(2, "LocationType")); //Selecting date and time HelperCallingMethods helperCallingMethods = new HelperCallingMethods(); helperCallingMethods.SelectingDateAndTime(); //Validating Start Date, End Date, Start Time,End Time GlobalDefinitions.TextDataFieldValidation("Start Date", DateTime.Today.ToString("dd/MM/yyyy"), DateTime.Parse(StartDateDropDown.GetAttribute("value")).ToString("dd/MM/yyyy")); GlobalDefinitions.TextDataFieldValidation("End Date", DateTime.Today.AddDays(14).ToString("dd/MM/yyyy"), DateTime.Parse(EndDateDropDown.GetAttribute("value")).ToString("dd/MM/yyyy")); GlobalDefinitions.TextDataFieldValidation("Start Time", GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"), DateTime.Parse(StartTime.GetAttribute("value")).ToString("hh:mmtt")); GlobalDefinitions.TextDataFieldValidation("End Time", GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"), DateTime.Parse(EndTime.GetAttribute("value")).ToString("hh:mmtt")); //Selecting SkillTrade or Credit radio button HelperCallingMethods.SelectingRadiobutton("//form/div[8]/div[@class='twelve wide column']/div/div[@class = 'field']", "skillTrades", GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")); string SkillTradeValue = GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade"); //Enter Skill-Exchange or Credit if (SkillTradeValue == "Skill-exchange") { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + "\n"); //Validating entered Skill exchange value GlobalDefinitions.TextDataFieldValidation("SkillExchange", GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange"), SkillExchangeTag.Text.Remove(SkillExchangeTag.Text.Length - 1, 1)); } else if (SkillTradeValue == "Credit") { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); //Validating entered Credit value GlobalDefinitions.TextDataFieldValidation("Credit", GlobalDefinitions.ExcelLib.ReadData(2, "Credit"), CreditAmount.GetAttribute("value")); } //Uploading file for Work Sample WorkSamples.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open", "File Upload"); autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); autoIt.Sleep(1000); //autoIt.Send(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory()) + "\\FileUploadTest.txt")); autoIt.Send(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\FileUploadTest.txt")); autoIt.Sleep(1000); autoIt.Send("{ENTER}"); autoIt.Sleep(2000); string[] FileSplitText = WorkSampleFileName.Text.Split('.'); string FileSplitTextName = FileSplitText[0]; //Validating uploaded worksample GlobalDefinitions.TextDataFieldValidation("WorkSamples", FileSplitTextName.ToString(), GlobalDefinitions.ExcelLib.ReadData(2, "FileName").ToString()); //selecting Active radio button HelperCallingMethods.SelectingRadiobutton("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", "isActive", GlobalDefinitions.ExcelLib.ReadData(2, "Active")); //Validating Active radio button selection GlobalDefinitions.RadiobuttonValidation("Active", "//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", "isActive", GlobalDefinitions.ExcelLib.ReadData(2, "Active")); //Clicking Save button Save.Click(); string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Share skill added"); }
public void AddService() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ServiceListing"); //click Shareskill button ShareSkillBtn.Click(); GlobalDefinitions.wait(2000); Base.test.Log(LogStatus.Info, "Starting adding Service"); //enter Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //enter Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //select Category if (Category.Displayed) { Category.Click(); } else { GlobalDefinitions.wait(2000); } for (int i = 0; i < CategoryOptions.Count; i++) { if (GlobalDefinitions.ExcelLib.ReadData(2, "Category") == CategoryOptions[i].Text) { CategoryOptions[i].Click(); Base.test.Log(LogStatus.Info, "Selected Category successfully"); } } GlobalDefinitions.wait(2000); //select SubCategory SubCategory.Click(); for (int i = 0; i < SubCategoryOptions.Count; i++) { if (GlobalDefinitions.ExcelLib.ReadData(2, "Sub Category") == SubCategoryOptions[i].Text) { SubCategoryOptions[i].Click(); Base.test.Log(LogStatus.Info, "Selected Sub Category successfully"); } } //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); //Click Service Type if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service") { OneOffServiceRadioBtn.Click(); Base.test.Log(LogStatus.Info, "Selected Service Type successfully"); } //Click Location Type if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site") { OnSiteRadioBtn.Click(); Base.test.Log(LogStatus.Info, "Selected Location Type successfully"); } //enter startDate StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); Global.GlobalDefinitions.wait(1000); //enter EndDate if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "End Date")))) { EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); } //enter start time and end time and for (int i = 0; i < DaysLabel.Count; i++) { switch (DaysLabel[i].Text) { case "Mon": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Mon Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Mon Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Mon End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Mon End Time")); } break; case "Tue": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Tue Start Time")))) { DaysCheckbox[i].Click(); Console.WriteLine("Inside tue if" + i + DaysLabel[i].Text); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tue Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Tue End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tue End Time")); } break; case "Wed": //string.IsNullOrEmpty(var) if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Wed Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Wed Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Wed End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Wed End Time")); } break; case "Thu": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Thu Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Thu Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Thu Start Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Thu End Time")); } break; case "Fri": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Fri Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Fri Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Fri End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Fri End Time")); } break; case "Sat": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Sat Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Sat Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Sat End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Sat End Time")); } break; case "Sun": if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "sun Start Time")))) { DaysCheckbox[i].Click(); StartTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Sun Start Time")); } if (!(string.IsNullOrEmpty(GlobalDefinitions.ExcelLib.ReadData(2, "Sun End Time")))) { EndTime[i].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Sun End Time")); } break; default: break; } } //Click SkillTrade if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange") { if (SkillExchangeRadioBtn.Selected == true) { Console.WriteLine("we are in if SkillExchangeRadioBtn.Selected == true"); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Exchange")); SkillExchange.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "Added skill Exchange successfully"); } } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit") { CreditRadioBtn.Click(); Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); Base.test.Log(LogStatus.Info, "Added credit successfully"); } //Approach 1: upload worksamples- if input field(text box) is present //WorkSamples.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2,"Work Samples")); //GlobalDefinitions.wait(3000); //Approach 2: Using AutoIT WorkSamples.Click(); AutoItX3 autoIT = new AutoItX3(); autoIT.WinActivate("Open"); Thread.Sleep(1000); //autoIT.Send("C:\\Users\\gredd\\Desktop\\test.txt"); autoIT.Send(GlobalDefinitions.ExcelLib.ReadData(2, "Work Samples")); Thread.Sleep(1000); autoIT.Send("{ENTER}"); //Click Active status if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == "Hidden") { HiddenRadioBtn.Click(); Base.test.Log(LogStatus.Info, "Selected status successfully"); } //click save Save.Click(); Base.test.Log(LogStatus.Info, "Saved Service successfully"); }