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); }
internal void EditShareSkill() { GlobalDefinitions.ExcelLib.PopulateInCollection(@"C:\Users\Rammy\Desktop\marsframework\MarsFramework\ExcelData\TestDataShareSkill.xlsx", "ShareSkill"); GlobalDefinitions.wait(30); //Click on ShareSkill button ShareSkillButton.Click(); //Wait GlobalDefinitions.wait(30); //Enter data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Title")); string TitleTextbox = Title.GetAttribute("Value"); if (TitleTextbox.Length == 0) { Assert.IsEmpty("Title"); } //Enter data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Description")); Assert.That(Description.Text, Is.EqualTo(GlobalDefinitions.ExcelLib.ReadData(3, "Description"))); CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Category")); CategoryDropDown.Click(); SubCategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "SubCategory")); SubCategoryDropDown.Click(); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Tags")); Tags.SendKeys(Keys.Enter); //Click on Hourly basis service or One-off service if (GlobalDefinitions.ExcelLib.ReadData(3, "Service Type") == "Hourly basis service") { Hourlybasisservice.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(3, "Service Type") == "One-off service") { OneOffservice.Click(); } //Click on On-site or Online if (GlobalDefinitions.ExcelLib.ReadData(3, "Location Type") == "On-site") { OnSite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(3, "Location Type") == "Online") { Online.Click(); } //Wait GlobalDefinitions.wait(60); //Convert excel dateformat to C# - Enter data in Staredate string dateformat = "dd / MM / yyyy"; string sdate = GlobalDefinitions.ExcelLib.ReadData(3, "Startdate"); string newStartDate = DateTime.Parse(sdate).ToString(dateformat); StartDateDropDown.SendKeys(newStartDate); string StartDate = StartDateDropDown.GetAttribute("Value"); if (StartDate.Length == 0) { Assert.IsEmpty("Startdate"); } //Convert excel dateformat to C# - Enter data in Enddate string edate = GlobalDefinitions.ExcelLib.ReadData(3, "Enddate"); string newEndDate = DateTime.Parse(edate).ToString(dateformat); EndDateDropDown.SendKeys(newEndDate); string EndDate = EndDateDropDown.GetAttribute("Value"); if (EndDate.Length == 0) { Assert.IsEmpty("Enddate"); } //Wait GlobalDefinitions.wait(60); //Click on a day Days.Click(); //Convert excel timeformat to C# - enter data in Starttime string timeformat = "hh:mmtt"; string stime = GlobalDefinitions.ExcelLib.ReadData(3, "Starttime"); string newStartTime = DateTime.Parse(stime).ToString(timeformat); StartTimeDropDown.SendKeys(newStartTime); string Start = StartTimeDropDown.GetAttribute("Value"); if (Start.Length == 0) { Assert.IsEmpty("Starttime"); } //Convert excel timeformat to C# - enter data in Endtime string etime = GlobalDefinitions.ExcelLib.ReadData(3, "Endtime"); string newEndTime = DateTime.Parse(etime).ToString(timeformat); EndTimeDropDown.SendKeys(newEndTime); string End = EndTimeDropDown.GetAttribute("Value"); if (End.Length == 0) { Assert.IsEmpty("Endtime"); } //Click on Skill-exchange or Credit if (GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade") == "Skill-exchange") { SkillExchangeOption.Click(); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade") == "Credit") { CreditOption.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Click on Active or Hidden ActiveOption.Click(); if (GlobalDefinitions.ExcelLib.ReadData(3, "Active") == "Active") { ActiveOption.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(3, "Active") == "Hidden") { HiddenOption.Click(); } //Upload a file WorkSample.Click(); GlobalDefinitions.wait(20); string path = GlobalDefinitions.ExcelLib.ReadData(3, "WorkSample"); AutoItX.WinActivate("File Upload"); //Wait GlobalDefinitions.wait(60); AutoItX.Send(path); AutoItX.Send("{ENTER}"); Save.Click(); Assert.That(ManageTitle.Text, Is.EqualTo("Voice Actor")); }
//[FindsBy(How = How.XPath, Using = "//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[4]")] //private IWebElement ItemToDelete { get; set; } //[FindsBy(How = How.XPath, Using = "")] //private IWebElement { get; set; } //[FindsBy(How = How.XPath, Using = "")] //private IWebElement { get; set; } #endregion internal void AddSkill() { //Populate the Excel sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "Skill"); ShareSkillBtn.Click(); Global.GlobalDefinitions.wait(5); TitleTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); DescriptionTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description")); CategoryDropdown.Click(); var category = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[3]/div[2]/div/div/select")); var selectElement = new SelectElement(category); selectElement.SelectByIndex(3); SubcategoryDropdown.Click(); var subcategory = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[3]/div[2]/div/div[2]/div[1]/select")); var selectElement1 = new SelectElement(subcategory); selectElement1.SelectByIndex(3); TagsTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); TagsTextbox.SendKeys(Keys.Enter); TagsTextbox1.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(3, "Tags")); TagsTextbox1.SendKeys(Keys.Enter); OneoffService.Click(); Thread.Sleep(500); HourlyService.Click(); Thread.Sleep(500); OnSite.Click(); Thread.Sleep(500); Online.Click(); StartdateTextbox.Click(); StartdateTextbox.SendKeys(DateTime.Now.AddDays(5).ToString("dd/MM/yyyy")); EnddateTextbox.Click(); EnddateTextbox.SendKeys(DateTime.Now.AddMonths(1).ToString("dd/MM/yyyy")); SunCheckBox.Click(); SunStartTime.Click(); SunStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); SunStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); SunStartTime.SendKeys(Keys.Up); SunEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); SunEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); SunEndTime.SendKeys(Keys.ArrowDown); MonCheckBox.Click(); MonStartTime.Click(); MonStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); MonStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); MonStartTime.SendKeys(Keys.Up); MonEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); MonEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); MonEndTime.SendKeys(Keys.ArrowDown); TueCheckBox.Click(); TueStartTime.Click(); TueStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); TueStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); TueStartTime.SendKeys(Keys.Up); TueEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); TueEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); TueEndTime.SendKeys(Keys.ArrowDown); WedCheckBox.Click(); WedStartTime.Click(); WedStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); WedStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); WedStartTime.SendKeys(Keys.Up); WedEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); WedEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); WedEndTime.SendKeys(Keys.ArrowDown); ThuCheckBox.Click(); ThuStartTime.Click(); ThuStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); ThuStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); ThuStartTime.SendKeys(Keys.Up); ThuEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); ThuEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); ThuEndTime.SendKeys(Keys.ArrowDown); FriCheckBox.Click(); FriStartTime.Click(); FriStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); FriStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); FriStartTime.SendKeys(Keys.Up); FriEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); FriEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); FriEndTime.SendKeys(Keys.ArrowDown); SatCheckBox.Click(); SatStartTime.Click(); SatStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); SatStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes")); SatStartTime.SendKeys(Keys.Up); SatEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); SatEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes")); SatEndTime.SendKeys(Keys.ArrowDown); SkillExchangeButton.Click(); SkillExchangeTag.Click(); SkillExchangeTag.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "SkillToExchange")); SkillExchangeTag.SendKeys(Keys.Enter); CreditButton.Click(); CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "CreditAmount")); PlusCircleIcon.Click(); //Upload file AutoItX3 autoIt = new AutoItX3(); autoIt.WinActivate("Open"); autoIt.Send(@"C:\Users\Nemesis\Pictures\TanslatePix\zodiac.jpg"); Thread.Sleep(500); autoIt.Send("{ENTER}"); Thread.Sleep(500); PlusCircleIcon.Click(); AutoItX3 autoIt1 = new AutoItX3(); autoIt1.WinActivate("Open"); Thread.Sleep(500); autoIt1.Send(@"C:\Users\Nemesis\Pictures\TanslatePix\doggie.jpg"); Thread.Sleep(500); autoIt1.Send("{ENTER}"); Thread.Sleep(500); RemoveItem.Click(); HiddenRadioButton.Click(); Thread.Sleep(1000); ActiveRadioButton.Click(); SaveButton.Click(); Global.GlobalDefinitions.wait(5); //Add Skill Verification ManageListingsTab.Click(); Global.GlobalDefinitions.wait(5); string ExpectedText = Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description"); string ActualText = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[4]")).Text; if (ExpectedText.Equals(ActualText)) { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Add Skill Successful"); String img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "AddSkill_Pass"); test.Log(LogStatus.Info, "Image example: " + img); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Add Skill UnSuccessful"); String img1 = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "AddSkill_Fail"); test.Log(LogStatus.Info, "Image example: " + img1); } }