// Availability SubCategory option internal void SelectSubCategory() { Thread.Sleep(1500); Actions action_SubCategory = new Actions(GlobalDefinitions.driver); action_SubCategory.MoveToElement(SubCategory).Build().Perform(); SubCategory.Click(); IList <IWebElement> AvailableSubCategory = SubCategory.FindElements(By.TagName("option")); int countSubCategory = AvailableSubCategory.Count; for (int i = 0; i < countSubCategory; i++) { if (AvailableSubCategory[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")) { AvailableSubCategory[i].Click(); Global.Base.test.Log(LogStatus.Info, "Select the available SubCategory"); } } }
internal void Addingdate() { Actions actions = new Actions(Global.GlobalDefinitions.driver); //Populate the Excel sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "Share_Skill"); //click on share skill SSbutton.Click(); Thread.Sleep(2000); //Click on title Title.Click(); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //clic on description Description.Click(); Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Click on Category actions.MoveToElement(Category).Build().Perform(); Thread.Sleep(1000); IList <IWebElement> Select_Cat = Category.FindElements(By.TagName("option")); Console.WriteLine("List of category" + Select_Cat); int categorycount = Select_Cat.Count; for (int i = 0; i < categorycount; i++) { if (Select_Cat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category")) { Select_Cat[i].Click(); Console.WriteLine("Category is" + Select_Cat[i].Text); Base.test.Log(LogStatus.Info, "Selected Category"); } } //Click on Sub Category actions.MoveToElement(SubCategory).Build().Perform(); Thread.Sleep(1000); IList <IWebElement> Select_SubCat = SubCategory.FindElements(By.TagName("option")); Console.WriteLine("List of category" + Select_SubCat); int Scategorycount = Select_SubCat.Count; for (int i = 0; i < Scategorycount; i++) { if (Select_SubCat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Sub-Category")) { Select_SubCat[i].Click(); Console.WriteLine("Category is" + Select_SubCat[i].Text); Base.test.Log(LogStatus.Info, "Selected Category"); } } //Add tags actions.MoveToElement(Tags).Build().Perform(); string tag1 = GlobalDefinitions.ExcelLib.ReadData(2, "Tags"); string tag2 = GlobalDefinitions.ExcelLib.ReadData(3, "Tags"); string tag3 = GlobalDefinitions.ExcelLib.ReadData(4, "Tags"); Tags.SendKeys(tag1); Tags.SendKeys(Keys.Enter); Thread.Sleep(2000); Tags2.Click(); // actions.MoveToElement(Tags2).Build().Perform(); Tags2.SendKeys(tag2); Thread.Sleep(1000); //actions.MoveToElement(Tags).Build().Perform(); //Tags.SendKeys(tag3); //Select service type actions.MoveToElement(ServiceType).Build().Perform(); IList <IWebElement> ST = ServiceType.FindElements(By.XPath("//div/input[@name='serviceType']/following-sibling :: label")); for (int i = 0; i < ST.Count; i++) { Console.WriteLine("service from web" + ST[i].Text); if (ST[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType")) { HourlyService.Click(); } else { One_off_service.Click(); } break; } //Select Location type actions.MoveToElement(LocationType).Build().Perform(); IList <IWebElement> LT = ServiceType.FindElements(By.XPath("//div/input[@name='locationType']/following-sibling :: label")); for (int i = 0; i < LT.Count; i++) { Console.WriteLine("service from web" + LT[i].Text); if (LT[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "LocationType")) { Onsite.Click(); } else { Online.Click(); } break; } //Click on start date Startdate.Click(); Thread.Sleep(1000); //Enter start date string s1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartDate"); string[] s = s1.Split(' '); Console.WriteLine("1st part of string:" + s[0]); Console.WriteLine("2nd part of string:" + s[1]); string SD = s[0]; Startdate.SendKeys(SD); //click on enddate Enddate.Click(); //Enter End date string E1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndDate"); string[] E = E1.Split(' '); Console.WriteLine("Enddate 1st part is:" + E[0]); Console.WriteLine("End date second part is:" + E[1]); string ED = E[0]; Enddate.SendKeys(ED); Thread.Sleep(1000); //Enter day actions.MoveToElement(Days).Build().Perform(); IList <IWebElement> Day_Name = Days.FindElements(By.XPath("//div[@class='ui checkbox']/input/following-sibling :: label")); Console.WriteLine("Days are" + Day_Name); IList <IWebElement> Day_check = Days.FindElements(By.XPath("//input[@tabindex='0' and @type='checkbox']")); Console.WriteLine("Day checkbox" + Day_check); Thread.Sleep(1000); int Day_Count = Day_Name.Count; int DayCheck_Count = Day_check.Count; for (int i = 0; i < Day_Count; i++) { if (Day_Name[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Day")) { int j = i; Day_check[j].Click(); Console.WriteLine("selected day is" + Day_Name[i]); } } //Enter starttime Start_Time.Click(); string t1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartTime"); Console.WriteLine("Starttime is:" + t1); Start_Time.SendKeys(t1); //Enter Endtime End_Time.Click(); string ET = Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndTime"); Console.WriteLine("Endtime is:" + ET); End_Time.SendKeys(ET); //Select SkillExchange actions.MoveToElement(Skill_trade).Build().Perform(); IList <IWebElement> Skill_E = Skill_trade.FindElements(By.XPath("//div/input[@name='skillTrades']/following-sibling :: label")); int SkillCount = Skill_E.Count; Console.WriteLine("count of radio buttons:" + SkillCount); for (int i = 0; i < SkillCount; i++) { if (Skill_E[i].Text == GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade")) { Console.WriteLine("Skil is" + Skill_E[i].Text); Skill_Exchange.Click(); actions.MoveToElement(Add_tags).Build().Perform(); string Tag = GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchange"); Add_tags.SendKeys(Tag); Base.test.Log(LogStatus.Info, "Selected skill"); } else { Credit.Click(); actions.MoveToElement(Add_credit).Build().Perform(); string Cr = GlobalDefinitions.ExcelLib.ReadData(2, "Credit"); Add_credit.SendKeys(Cr); } break; } //Click on Worksample PlusIcon.Click(); //Performing the upload file operation using AutoIT AutoItX3 autoIT = new AutoItX3(); autoIT.WinActivate("Open"); Thread.Sleep(3000); string sample1 = GlobalDefinitions.ExcelLib.ReadData(2, "WorkSample"); Console.WriteLine("file path is" + sample1); Thread.Sleep(2000); autoIT.Send(@sample1); Thread.Sleep(3000); autoIT.Send("{Enter}"); Thread.Sleep(2000); //Downloading the file Download.Click(); //Deleting a file Delete.Click(); Thread.Sleep(500); actions.MoveToElement(Active).Build().Perform(); IList <IWebElement> Active_Name = Active.FindElements(By.XPath("//div[@class='ui radio checkbox']/input[@name='isActive']/following-sibling :: label")); Console.WriteLine("Days are" + Active_Name); IList <IWebElement> Active_radio = Active.FindElements(By.XPath("//input[@name='isActive' and @type='radio']")); Console.WriteLine("Day checkbox" + Active_radio); Thread.Sleep(1000); int Active_Count = Active_Name.Count; for (int i = 0; i < Active_Count; i++) { if (Active_Name[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Active")) { int j = i; Active_radio[j].Click(); } } //click on save actions.MoveToElement(Buttons).Build().Perform(); IList <IWebElement> BT = ServiceType.FindElements(By.XPath("//input[@type='button']")); for (int i = 0; i < BT.Count; i++) { Console.WriteLine("Button from web" + BT.Count); if (GlobalDefinitions.ExcelLib.ReadData(2, "Buttons") == "Save") { Save.Click(); } else { Cancel.Click(); } break; } string text = Global.GlobalDefinitions.driver.Title; if (text == "ServiceListing") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Share skill page"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Not valid page"); } }
public void ShareProfile(string Decission) { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); Thread.Sleep(1000); //Enter Details to title filed Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Enter details to description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select the category IList <IWebElement> CategoryOptions = Category.FindElements(By.TagName("option")); for (int i = 0; i < CategoryOptions.Count; i++) { if (CategoryOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category")) { CategoryOptions[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Category selected"); } } //------------------------------------------------------------------------------------- //Select Subcategory IList <IWebElement> SubcategoryOptions = SubCategory.FindElements(By.TagName("option")); for (int i = 0; i < SubcategoryOptions.Count; i++) { if (SubcategoryOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Subcategory")) { SubcategoryOptions[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Subcategory Selected"); } } //------------------------------------------------------------------------------------------- //Enter a Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tag1")); Tags.SendKeys(Keys.Enter); //Define Lists of radio button options in Skill Share page IList <IWebElement> ServiceTypeOptions = GlobalDefinitions.driver.FindElements(By.XPath("//div[@class='field']/div")); IList <IWebElement> Radiobtn = GlobalDefinitions.driver.FindElements(By.XPath("//div[@class='field']/div/input")); Thread.Sleep(1000); //--------------------------------------------------------------------------------------------- //Select Service Type for (int i = 0; i < ServiceTypeOptions.Count; i++) { if (ServiceTypeOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Service Type")) { Radiobtn[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Service Type Selected"); } } //------------------------------------------------------------------------------------------ //Select Location Type for (int i = 0; i < ServiceTypeOptions.Count; i++) { if (ServiceTypeOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Location Type")) { Radiobtn[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Location Type Selected"); } } //----------------------------------------------------------------------------------------------- //Enter start date StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); Console.WriteLine(GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //StartDate.SendKeys("06/16/2019"); Thread.Sleep(1000); //Enter end date //EndDate.Clear(); EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); // --------------------------------------------------------------------------------- //Select Available Date and Time List <int> AvailableDays = new List <int> { 0, 1, 0, 1, 0, 0, 0 }; IList <IWebElement> Dayspath = Global.GlobalDefinitions.driver.FindElements(By.XPath("//input[@name='Available']")); IList <IWebElement> StartTime = Global.GlobalDefinitions.driver.FindElements(By.XPath("//input[@name='StartTime']")); IList <IWebElement> EndTime = Global.GlobalDefinitions.driver.FindElements(By.XPath("//input[@name='EndTime']")); if (AvailableDays[0] == 1) { Dayspath[0].Click(); StartTime[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartTime")); EndTime[0].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndTime")); } if (AvailableDays[1] == 1) { Dayspath[1].Click(); StartTime[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "StartTime")); StartTime[1].SendKeys(Keys.ArrowDown); StartTime[1].SendKeys(Keys.ArrowDown); Console.WriteLine(GlobalDefinitions.ExcelLib.ReadData(3, "StartTime")); EndTime[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "EndTime")); EndTime[1].SendKeys(Keys.ArrowDown); } if (AvailableDays[2] == 1) { Dayspath[2].Click(); StartTime[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "StartTime")); EndTime[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "EndTime")); } if (AvailableDays[3] == 1) { Dayspath[3].Click(); StartTime[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(5, "StartTime")); StartTime[3].SendKeys(Keys.ArrowDown); StartTime[3].SendKeys(Keys.ArrowDown); EndTime[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(5, "EndTime")); EndTime[3].SendKeys(Keys.ArrowDown); } if (AvailableDays[4] == 1) { Dayspath[4].Click(); StartTime[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(6, "StartTime")); EndTime[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(6, "EndTime")); } if (AvailableDays[5] == 1) { Dayspath[5].Click(); StartTime[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(7, "StartTime")); EndTime[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(7, "EndTime")); } if (AvailableDays[6] == 1) { Dayspath[6].Click(); StartTime[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(8, "StartTime")); EndTime[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(8, "EndTime")); } Thread.Sleep(1000); //-------------------------------------------------------------------------------- //Select Skill trade for (int i = 0; i < ServiceTypeOptions.Count; i++) { Console.WriteLine(ServiceTypeOptions[i].Text); if (ServiceTypeOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")) { Radiobtn[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skill Trade Selected"); } } //---------------------------------------------------------------------------------------- //Enter Skill Exchange tags SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Exchange")); SkillExchange.SendKeys(Keys.Enter); //---------------------------------------------------------------------------------------- //Work Samples File Upload Thread.Sleep(2000); workSamplesUpload.Click(); AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Open"); //Activate the window autoit.Send(@"C:\Users\dell\Desktop\DESKTOP_AKILA\MVP studio\Mars Competition1\MarsFramework\MarsFramework\download.jpg"); Thread.Sleep(2000); autoit.Send("{ENTER}"); //-------------------------------------------------------------------------------------------- //Select Active for (int i = 0; i < ServiceTypeOptions.Count; i++) { Console.WriteLine(ServiceTypeOptions[i].Text); if (ServiceTypeOptions[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Active")) { Radiobtn[i].Click(); Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Active Selected"); } } if (Decission == "Save") { SaveBtn.Click(); } else { CancelBtn.Click(); } }
public void EditSkills() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ManageListings"); Thread.Sleep(4000); //Click on ManageListings button Thread.Sleep(5000); Global.GlobalDefinitions.driver.Navigate().Refresh(); ML.Click(); Thread.Sleep(4000); while (true) { var j = 1; while (j <= 10) { // identify 2nd row of table. Then extact the text and assign to a variable var Category1 = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[" + j + "]/td[2]")).Text; var EditBtn = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[" + j + "]/td[8]/i[2]")); //compare the text with the expected text. "Graphics & Design" if (Category1 == (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category1"))) { //Click on Edit Button EditBtn.Click(); Thread.Sleep(3000); // Adding Title Title.Clear(); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Thread.Sleep(500); //Add Description Description.Clear(); Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Thread.Sleep(3000); //SaveBtn.Click(); Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); //Add Category Thread.Sleep(1500); //Actions action = new Actions(GlobalDefinitions.driver); //action.Click(Category); Category.Click(); //action.MoveToElement(Category).Build().Perform(); Console.WriteLine("Clicked on the Category"); Thread.Sleep(2000); IList <IWebElement> CategoryList = Category.FindElements(By.TagName("option")); int Count = CategoryList.Count; Thread.Sleep(500); for (int i = 0; i < Count; i++) { Console.WriteLine("in"); if (CategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category").Trim()) { Thread.Sleep(1000); CategoryList[i].Click(); Base.test.Log(LogStatus.Info, " Category Selected"); } } //Add SubCategory SubCategory.Click(); Console.WriteLine("Clicked on the SubCategory"); Thread.Sleep(2000); IList <IWebElement> SubCategoryList = SubCategory.FindElements(By.TagName("option")); //int count = SubCatogeryList.Count; Thread.Sleep(500); for (int i = 0; i < SubCategoryList.Count; i++) { if (SubCategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")) //if (SubCatogeryList[i].Text == " Other".Trim()) { Thread.Sleep(1000); SubCategoryList[i].Click(); Base.test.Log(LogStatus.Info, " SubCategory Selected"); } } // Add Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); // Select Service Type Thread.Sleep(1000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service") { ServiceType.Click(); } else { Servicetype.Click(); } Base.test.Log(LogStatus.Info, "Service type Edited successfully"); //Select Location Type Thread.Sleep(1000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online") { LocationType.Click(); } else { Locationtype.Click(); } Base.test.Log(LogStatus.Info, "Location Type Edited successfully"); //Monday Check Box Selection Thread.Sleep(2000); Boolean X = MondayCheckBox.Selected; if (X == false) { MondayCheckBox.Click(); } MondayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); Thread.Sleep(1000); MondayEndTime.Clear(); MondayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); Thread.Sleep(1000); //Tuesday Selection //TuesdayCheckBox.Click(); //TuesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Start Time")); //TuesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "End Time")); //Days selection Thursdaycheckbox.Click(); Thread.Sleep(2000); ThursdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); ThursdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); //Selecting Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange") { SkillTrade.Click(); } else { Skilltrade.Click(); } Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); // Enter Skill Exchange AutoItX3 autoItx = new AutoItX3(); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); autoItx.Send("{Enter}"); Thread.Sleep(3000); Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); //Upload WorkSample Thread.Sleep(4000); WorkSample.Click(); Thread.Sleep(1000); AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Open"); autoit.Send(@"c:\users\rajesh jasti\Documents\Worksamples.xlsx"); Thread.Sleep(5000); autoit.Send("{Enter}"); Base.test.Log(LogStatus.Info, "Work Sample Updated successfully"); // select Active Thread.Sleep(1000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == "Active") { ActiveBtn.Click(); } else { Hidden.Click(); } //Click on Save Button SaveBtn.Click(); Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); return; } j++; } var btnNext = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div/button[4]")); btnNext.Click(); } var Title1 = (Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[3]/td[2]")).Text); Assert.AreEqual("Test Analyst", Title1); Console.WriteLine(" Skills Edited Successfully"); }
////Click on View Button //[FindsBy(How = How.XPath, Using = "//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[1]/td[8]/i[1]")] //private IWebElement ViewBtn { get; set; } #endregion #region Add Skills public void AddShareSkills() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills"); Thread.Sleep(2000); //Click on ShareSkills Thread.Sleep(5000); Shareskills.Click(); //Click on Title Thread.Sleep(5000); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Thread.Sleep(500); //Click on Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Info, "Description Added Sucessfully"); //Add Category Thread.Sleep(4000); //Actions action = new Actions(GlobalDefinitions.driver); //action.Click(Category); Category.Click(); //action.MoveToElement(Category).Build().Perform(); Console.WriteLine("Clicked on the Category"); Thread.Sleep(2000); IList <IWebElement> CategoryList = Category.FindElements(By.TagName("option")); int Count = CategoryList.Count; Thread.Sleep(500); for (int i = 0; i < Count; i++) { Console.WriteLine("in"); if (CategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category").Trim()) //if (CategoryList[i].Text == " Graphics & Design ".Trim()) { Thread.Sleep(1000); CategoryList[i].Click(); Base.test.Log(LogStatus.Info, " Category Selected"); } } //Add SubCategory SubCategory.Click(); Console.WriteLine("Clicked on the SubCategory"); Thread.Sleep(2000); IList <IWebElement> SubCatogeryList = SubCategory.FindElements(By.TagName("option")); //int count = SubCatogeryList.Count; Thread.Sleep(500); for (int i = 0; i < SubCatogeryList.Count; i++) { if (SubCatogeryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory").Trim()) { Thread.Sleep(1000); SubCatogeryList[i].Click(); Base.test.Log(LogStatus.Info, " SubCategory Selected"); } } // Add Tags AutoItX3 autoIt = new AutoItX3(); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); autoIt.Send("{Enter}"); Base.test.Log(LogStatus.Info, " Tags Added successfully"); // Select Service Type Thread.Sleep(1000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == " Hourly badis sevice ") { Servicetype.Click(); } else { ServiceType.Click(); } Base.test.Log(LogStatus.Info, "Service type Added successfully"); //Select Location Type Thread.Sleep(1000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site") { Locationtype.Click(); } else { LocationType.Click(); } Base.test.Log(LogStatus.Info, "Location Type Edited successfully"); //Monday selection MondayCheckBox.Click(); MondayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); Thread.Sleep(1000); MondayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); Thread.Sleep(1000); //Tuesday Selection TuesdayCheckBox.Click(); TuesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Start Time")); TuesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "End Time")); //Wednesday Selection Wednesdaycheckbox.Click(); WednesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "Start Time")); WednesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "End Time")); //Selecting Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit") { Thread.Sleep(1000); Skilltrade.Click(); } else { Thread.Sleep(1000); SkillTrade.Click(); } Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); // Enter Credit Thread.Sleep(1000); Credit.Clear(); Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); Thread.Sleep(1000); Base.test.Log(LogStatus.Info, " Service Listing updated successfully"); //Upload WorkSample Thread.Sleep(3000); WorkSample.Click(); Thread.Sleep(1000); AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Open"); autoit.Send(@"c:\users\rajesh jasti\Documents\ProfilePhoto.jpg"); Thread.Sleep(2000); autoit.Send("{Enter}"); Base.test.Log(LogStatus.Info, "Image Edited successfully"); //Selecting Active Thread.Sleep(4000); if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == "Hidden") { Hidden.Click(); } else { ActiveBtn.Click(); } //Click on Save Button SaveBtn.Click(); }
public void AddNewSkill() { //Populate the Excel Sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Shareskills"); GlobalDefinitions.wait(1); //Enter a Title Title.SendKeys(ExcelLib.ReadData(2, "Title")); Base.test.Log(LogStatus.Info, "Added Title successfully"); // Enter description Description.SendKeys(ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Info, "Added description successfully"); //Select a category from dropdown GlobalDefinitions.wait(2); //Thread.Sleep(500); Actions action = new Actions(GlobalDefinitions.driver); action.MoveToElement(SkillCategory).Build().Perform(); Thread.Sleep(1000); IList <IWebElement> SkillCategorylist = SkillCategory.FindElements(By.TagName("option")); int count = SkillCategorylist.Count; Thread.Sleep(1500); for (int i = 1; i < count; i++) { if (SkillCategorylist[i].Text == ExcelLib.ReadData(2, "Category").Trim()) { Thread.Sleep(500); SkillCategorylist[i].Click(); Base.test.Log(LogStatus.Info, "Added category successfully"); } } //Select a subcategory from dropdown GlobalDefinitions.wait(2); action.MoveToElement(SubCategory).Build().Perform(); GlobalDefinitions.wait(2); IList <IWebElement> SubCategorylist = SubCategory.FindElements(By.TagName("option")); for (int i = 0; i < SubCategorylist.Count; i++) { if (SubCategorylist[i].Text == ExcelLib.ReadData(2, "SubCategory")) { SubCategorylist[i].Click(); Base.test.Log(LogStatus.Info, "Added Subcategory successfully"); } } //Add Tag GlobalDefinitions.wait(2); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tag")); Tags.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "Added tag successfully"); //Select Service type GlobalDefinitions.wait(2); string ExpectedService = GlobalDefinitions.ExcelLib.ReadData(2, "Service"); string ActualService = ServiceType1.Text; if (ExpectedService == ActualService) { ServiceType1.Click(); } else { ServiceType2.Click(); } //Select location type Thread.Sleep(2000); GlobalDefinitions.wait(2); string ExpectedLocation = ExcelLib.ReadData(2, "Location"); string ActualLocation = Location1.Text; if (ExpectedLocation == ActualLocation) { Location1.Click(); } else { GlobalDefinitions.wait(2); Location2.Click(); } ////Select start Date GlobalDefinitions.wait(2); //StartDate.SendKeys(ExcelLib.ReadData(2, "StartDate")); //StartDate.SendKeys(Keys.Tab); Thread.Sleep(2000); string sysday = DateTime.Today.Day.ToString(); StartDate.SendKeys(sysday); string sysmonth = DateTime.Today.Month.ToString(); StartDate.SendKeys(sysmonth); // Select EndDate Thread.Sleep(2000); // EndDate.SendKeys(ExcelLib.ReadData(2, "EndDate")); EndDate.SendKeys("20/11/2020"); GlobalDefinitions.wait(2); //Select Available day Thread.Sleep(2000); AvailableDay.Click(); // Select StartTime Thread.Sleep(2000); StartTime.SendKeys(ExcelLib.ReadData(2, "StartTime")); Thread.Sleep(2000); // Select EndTime GlobalDefinitions.wait(1); EndTime.SendKeys(ExcelLib.ReadData(2, "EndTime")); Base.test.Log(LogStatus.Info, "Added avilable date and time successfully"); Thread.Sleep(2000); //Select Skill Trade GlobalDefinitions.wait(2); string ExpectedSkillTrade = ExcelLib.ReadData(2, "Skill Trade"); string ActualSkillTrade = SkillExchange.Text; if (ExpectedSkillTrade == ActualSkillTrade) { SkillExchange.Click(); //Enter skill for exchange SkillExchangeTag.SendKeys(ExcelLib.ReadData(2, "Skillexchange")); } else { Credit.Click(); //Enter rate CreditRate.Clear(); CreditRate.SendKeys(ExcelLib.ReadData(2, "Rate")); } //Upload WorkSample Images string MyWork = ExcelLib.ReadData(2, "UploadImage"); WorkSample.Click(); AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Open"); autoit.Send(MyWork); GlobalDefinitions.wait(1); autoit.Send("{Enter}"); Base.test.Log(LogStatus.Info, "Uploaded image successfully"); Thread.Sleep(2000); //Select active/ Hidden button GlobalDefinitions.wait(1); GlobalDefinitions.wait(2); string ExpectedAction = ExcelLib.ReadData(2, "Location"); string ActualAction = ActiveBtn.Text; if (ExpectedAction == ActualAction) { ActiveBtn.Click(); } else { GlobalDefinitions.wait(2); HiddenBtn.Click(); } //Check if save button enabled GlobalDefinitions.wait(2); if (SaveBtn.Enabled) { // Click on Save button GlobalDefinitions.wait(2); SaveBtn.Click(); Thread.Sleep(10000); try { //Check for Skill share success message Thread.Sleep(2000); GlobalDefinitions.wait(2); String ExpectedMessage = "Service Listing Added Successfully"; Thread.Sleep(10000); String ActualMessage = driver.FindElement(By.CssSelector("div.ns-box-inner")).Text; Assert.AreEqual(ExpectedMessage, ActualMessage); Base.test.Log(LogStatus.Info, "Skill saved Successfully"); } catch (Exception) { Base.test.Log(LogStatus.Info, "Skill saved Successfully"); } } else { SaveScreenShotClass.SaveScreenshot(driver, "Save button not enabled"); Base.test.Log(LogStatus.Info, "Save button not enabled"); } //Search for the Shared skill in Manage Listing page GlobalDefinitions.wait(2); //Click on manage listing driver.FindElement(By.LinkText("Manage Listings")).Click(); Thread.Sleep(1000); //Check if navigated to service listing page try { string Expected = "Manage Listings"; string Actual = driver.FindElement(By.XPath("//div[@id='listing-management-section']/div[2]/h2")).Text; Assert.AreEqual(Expected, Actual); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Navigated to manage listing page"); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Navigated to manage listing page"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } catch (Exception) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Could not navigate to Manage listing page"); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Could not navigate to Manage listing page"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } //Check if the added skill is present in the Manage listings GlobalDefinitions.wait(2); string ExpectedTitle = ExcelLib.ReadData(2, "Title"); string BeforeXPath = "//div[@id='listing-management-section']/div[2]/div/table/tbody/tr["; string AfterXpath = "]/td[3]"; for (int i = 1; i <= 5; i++) { GlobalDefinitions.wait(2); string ColElements = driver.FindElement(By.XPath(BeforeXPath + i + AfterXpath)).Text; if (ColElements.Contains(ExpectedTitle)) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Skill present in Manage Listing "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill present in Manage Listing"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); break; } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Skill not present in Manage Listing "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill not present in Manage Listing"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } } }