internal void EditShareSkill() { //Enabling the Share Skill Button ShareSkillButton.Click(); //Navigating to the Share Skill Page GlobalDefinitions.driver.Navigate().GoToUrl("http://localhost:5000/Home/ServiceListing"); //Populate the Excel Sheet from ShareSkillDetails sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkillDetails"); GlobalDefinitions.wait(5); //Reading the Excel file-Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); GlobalDefinitions.wait(5); //Reading the Excel file-Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); GlobalDefinitions.wait(5); //Selecting the Category Dropdown SelectElement categoryDropdown = new SelectElement(CategoryDropDown); //Initializing the Expected Category for Assertion/ Reading the Excel File-Category var expectedCategory = GlobalDefinitions.ExcelLib.ReadData(2, "Category"); categoryDropdown.SelectByText(expectedCategory); GlobalDefinitions.wait(5); //Selecting the Subcategory Dropdown SelectElement subCategorydropdown = new SelectElement(SubCategoryDropDown); //Reading the excel file - Subcategory subCategorydropdown.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Select Subcategory")); GlobalDefinitions.wait(5); //Clearing the existing tags before sending new Tags/Reading the Excel File - Tags Tags.Clear(); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Environment.NewLine); //Clicking the Service Type radio button HourlyBasisService.Click(); OneOffService.Click(); //Clicking the Location Type radio button OnSiteLocationType.Click(); OnlineLocationType.Click(); //Clicking the Skill Trade radio button (Skill-exchange) SkillExchangeBtn.Click(); GlobalDefinitions.wait(5); //Reading the Excel File - Skill Exchange Tags SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Exchange")); //Clicking the Skill Trade radio button (Credit) CreditOptionBtn.Click(); GlobalDefinitions.wait(5); //Reading the Excel File - Credit Charge CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); //Clicking the Active radio button ActiveOption.Click(); HiddenOption.Click(); GlobalDefinitions.wait(10); //Populate the Excel Sheet from Time Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Time"); //Reading the excel file for StartDate StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //Reading the excel file for EndDate EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); //Using a for loop for reading the excel file including the days[Checkboxes] for (var i = 2; i <= 8; i++) { //Reading the days checkbox element starting on the 2nd row [i-2] AvailableCheckBoxes[i - 2].Click(); //Readtime = converting the string format to Date time format (see GlobalDefinitions changes) var excelStartTime = GlobalDefinitions.ExcelLib.ReadTime(i, "Start Time"); //passing the value of excelStartTime as ex: (0700am) since the system is not accepting spaces var startTime = excelStartTime.ToString("hhmmtt"); //Readtime = converting the string format to Date time format (see GlobalDefinitions changes) var excelEndTime = GlobalDefinitions.ExcelLib.ReadTime(i, "End Time"); var endTime = excelEndTime.ToString("hhmmtt"); //Reading data from excel file starting on the 2nd row StartTimes[i - 2].SendKeys(startTime); EndTimes[i - 2].SendKeys(endTime); } //Saving Skills Save.Click(); GlobalDefinitions.wait(20); //Assertion if the actual category is the same as the expected category var actualCategory = GlobalDefinitions.driver.FindElement(By.XPath($"//td[normalize-space()='{expectedCategory}']")).Text; Assert.AreEqual(actualCategory, expectedCategory); }
public void ShareskillListings() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); Thread.Sleep(1000); //Click on Share Skill Button Shareskillbutton.Click(); Thread.Sleep(1000); //Enter the Details //Enter Title from Excel Sheet Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Thread.Sleep(1000); //Enter Description from Excel Sheet Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Thread.Sleep(1000); //Click on Category dropdown box Category.Click(); Thread.Sleep(1000); //Select cartegory option from excel sheet by iterating the list of elements //I have declared CategoryOption as a IList<Iwebelement> int count = CategoryOption.Count; for (int i = 0; i < count; i++) { if (CategoryOption[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "CategoryOption")) { CategoryOption[i].Click(); } } Thread.Sleep(500); //Click on subcategory drop down box Subcategory.Click(); Thread.Sleep(1000); //Click on 3 option from the dropdown int countsubcat = SubcategoryOption.Count; for (int i = 0; i < countsubcat; i++) { if (SubcategoryOption[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategoryOption")) { SubcategoryOption[i].Click(); } } Thread.Sleep(500); //Enter Tag from the Excel sheet Tag.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Thread.Sleep(500); Tag.SendKeys(Keys.Enter); //Service Type as One-off service if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Oneoff service") { OneOffService.Click(); } else { HourlyBasisService.Click(); } Thread.Sleep(500); //Location Type as On-site if (GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") == "Onsite") { OnSite.Click(); } else { Online.Click(); } Thread.Sleep(500); //Enter Strt and End dates of Available days startDate.Click(); Thread.Sleep(500); startDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); Thread.Sleep(500); endDate.Click(); endDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); Thread.Sleep(500); //Enter the Available days and their Start and End Time from the Excel Sheet String availabledays = GlobalDefinitions.ExcelLib.ReadData(2, "Available"); String starttimes = GlobalDefinitions.ExcelLib.ReadData(2, "StartTime"); String endtimes = GlobalDefinitions.ExcelLib.ReadData(2, "EndTime"); String[] availabledaysarray = new String[] { }; availabledaysarray = availabledays.Split(','); int arraycount = availabledaysarray.Count(); String[] starttimesarray = new String[] { }; starttimesarray = starttimes.Split(','); int starttimecount = starttimesarray.Count(); String[] endtimesarray = new String[] { }; endtimesarray = endtimes.Split(','); int endtimecount = endtimesarray.Count(); for (int i = 0; i < arraycount; i++) { switch (availabledaysarray[i]) { case "sun": sunday.Click(); sunstarttime.SendKeys(starttimesarray[i]); sunendTime.SendKeys(endtimesarray[i]); break; case "mon": monday.Click(); monstarttime.SendKeys(starttimesarray[i]); monendTime.SendKeys(endtimesarray[i]); break; case "tue": tuesday.Click(); tuestarttime.SendKeys(starttimesarray[i]); tueendTime.SendKeys(endtimesarray[i]); break; case "wed": wednesday.Click(); wedstarttime.SendKeys(starttimesarray[i]); wedendTime.SendKeys(endtimesarray[i]); break; case "thu": thursday.Click(); thustarttime.SendKeys(starttimesarray[i]); thuendTime.SendKeys(endtimesarray[i]); break; case "fri": friday.Click(); fristarttime.SendKeys(starttimesarray[i]); friendTime.SendKeys(endtimesarray[i]); break; case "sat": saturday.Click(); satstarttime.SendKeys(starttimesarray[i]); satendTime.SendKeys(endtimesarray[i]); break; } } //Skill Trade as Credit/SkillExchange if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == "Credit") { credit.Click(); Thread.Sleep(500); //Credit charge as 6 per hour from Excel sheet creditCharge.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "CreditCharges")); Thread.Sleep(500); } else { skillExchange.Click(); Thread.Sleep(500); skillexchangetag.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchangetag")); Thread.Sleep(500); } //Work samples workSample.Click(); AutoItX3 autolt = new AutoItX3(); autolt.WinActivate("Open"); autolt.Send(GlobalDefinitions.ExcelLib.ReadData(2, "WorkSample")); //autolt.Send(@"E:\Competition Task1\Mars Automation framework\MarsFramework\MarsFramework\Empty.docx"); Thread.Sleep(1000); autolt.Send("{ENTER}"); //Set Active as Hidden/Active if (GlobalDefinitions.ExcelLib.ReadData(2, "ActiveService") == "Hidden") { Hidden.Click(); } else { Active.Click(); } //Save the form Save.Click(); Thread.Sleep(1000); }