private void selectSkillTrade(IWebElement element, string skillTrade) { if (skillTrade == "Skill-Exchange") { element.FindElement(By.XPath("//div[@class='ui radio checkbox']/input[@value = 'true' and @name='skillTrades']")).Click(); if (SkillExchange.Displayed && SkillExchange.Enabled) { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); } else { Console.WriteLine("Skill Exchange textbox is not avaiable"); return; } } else if (skillTrade == "Credit") { IWebElement credit = element.FindElement(By.XPath("//div[@class='ui radio checkbox']/input[@value = 'false' and @name = 'skillTrades']")); credit.Click(); GlobalDefinitions.wait(5); if (CreditAmount.Displayed && CreditAmount.Enabled) { CreditAmount.SendKeys("1"); } else { Console.WriteLine("Credit textbox is not avaiable"); return; } } }
internal void FillSchedrule(int DataRow) { //Check if the user is able to click on a "Start Date" for the "Available days" field StartDateDropDown.Click(); StartDateDropDown.Clear(); StartDateDropDown.SendKeys(GlobalDefinitions.ReadData(DataRow, "StartDate")); //Check if the user is able to click on a "End Date" for the "Available days" field EndDateDropDown.Click(); EndDateDropDown.Clear(); EndDateDropDown.SendKeys(GlobalDefinitions.ReadData(DataRow, "EndDate")); //Check if the user is able to click on a "Day" checkbox for the "Available days" field for (var i = 1; i <= 5; i++) { Days[i].Click(); } //Check if the user is able to select a "Start Time" for the "Available days" field StartTimeDropDown.SendKeys(GlobalDefinitions.ReadData(DataRow, "StartTime")); //Check if the user is able to select a "End Time" for the "Available days" field EndTimeDropDown.SendKeys(GlobalDefinitions.ReadData(DataRow, "EndTime")); //Check if the user is able to click on "Credits" as the "Skill Trade" option SkillTradeCreditsOption.Click(); //Check if the user is able to enter a number for the "Credits" field CreditAmount.Clear(); CreditAmount.SendKeys(GlobalDefinitions.ReadData(DataRow, "Credit")); //Check if the user is able to set an option for the "Active" field ActiveOption.Click(); }
internal void EnterShareSkill() { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); //Click on Join button ShareSkillButton.Click(); // Enter Title on ShareSkill page Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); // Enter discription on ShareSkill page Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); // Select category dropdown on share skil page CategoryDropDown.Click(); // Enter tag names in taxbox Tags.Click(); //Select service type type on share skill page ServiceTypeOptions.Click(); // Select location type on share skill page LocationTypeOption.Click(); // Sorting Start time StartTime.Click(); // Select start date drop down StartDateDropDown.Click(); // Select End date drop down on share skill page EndDateDropDown.Click(); // Select available days Days.Click(); // Select start time on share skill page StartTimeDropDown.Click(); // Select end time on share skill page EndTimeDropDown.Click(); // Click on skill trade option SkillTradeOption.Click(); // Select skill exchange option SkillExchange.Click(); // Enter credit ammount on share skill page CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "credit amount")); // Click on Active option on share skill page ActiveOption.Click(); // click on save button on share skill page Save.Click(); Thread.Sleep(2000); }
internal void EditDetails(int dataRow) { GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "SkillDetails"); Thread.Sleep(3000); SkillTradeCredit.Click(); CreditAmount.Clear(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(dataRow, "Credit")); }
//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")); }
internal void AddShareSkill() { ExcelLib.PopulateInCollection(Base.ExcelPath, "ManageListings"); GlobalDefinitions.WaitForElement(ShareSkillButton, 30); ShareSkillButton.Click(); GlobalDefinitions.WaitForElement(Title, 30); Title.SendKeys(ExcelLib.ReadData(2, "Title")); Description.SendKeys(ExcelLib.ReadData(2, "Description")); Category(CategoryDropDown, ExcelLib.ReadData(2, "Category")); SubCategory(SubCategoryDropDown, ExcelLib.ReadData(2, "Sub Category")); Tags.SendKeys(ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); OneOff.Click(); OnLine.Click(); StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Start Date")); EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "End Date")); Sunday.Click(); SundayStartTime.SendKeys(ExcelLib.ReadData(2, "Sunday Start Time")); SundayEndTime.SendKeys(ExcelLib.ReadData(2, "Sunday End Time")); Monday.Click(); MondayStartTime.SendKeys(ExcelLib.ReadData(2, "Monday Start Time")); MondayEndTime.SendKeys(ExcelLib.ReadData(2, "Monday End Time")); Tuesday.Click(); TuesdayStartTime.SendKeys(ExcelLib.ReadData(2, "Monday Start Time")); TuesdayEndTime.SendKeys(ExcelLib.ReadData(2, "Monday End Time")); CreditOption.Click(); if (SkillExchangeOption.Selected) { SkillExchange.SendKeys(ExcelLib.ReadData(2, "Skill Exchange")); } else { CreditAmount.SendKeys(ExcelLib.ReadData(2, "Credit")); } Hidden.Click(); Save.Click(); }
internal void SelectSkillTrade() { if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == "Skill-Exchange") { optSkillExchange.Click(); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); } else { optCredit.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } }
public void AddNewShareSkill() { #region Navigate to Share Skills Page // Click on Share Skills Page ShareSkills.Click(); Thread.Sleep(1000); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); // Enter Title Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Base.test.Log(LogStatus.Info, "Title has been successfully entered"); //Enter description Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Info, "Description has been successfully entered"); //click on category dropdown menu Thread.Sleep(500); Category.Click(); Thread.Sleep(1000); //Select the category ProgrammingandTech.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category")); Thread.Sleep(1000); //Click on subcatogory drop down option Thread.Sleep(1000); SubCategory.Click(); //Select the Sub-Category option SubCategory.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Subcategory")); SubCategory.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "SubCategory has been successfully entered"); QA.Click(); //Enter Tags Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "TagName has been successfully entered"); //Select service type //ServiceTypeHourly.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service") { ServiceTypeOneOff.Click(); } //Select Location Type //LocationTypeOnline.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online") { LocationTypeOnline.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site") { LocationTypeOnsite.Click(); } //Click the start date StartDate.Click(); Thread.Sleep(500); //Select the date Thread.Sleep(500); StartDate.SendKeys(Keys.Backspace); StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //Select the end Date Thread.Sleep(1000); EndDate.SendKeys(Keys.Backspace); EndDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); //Select the Days available selectDays.Click(); Thread.Sleep(500); //Select starttime Thread.Sleep(1000); StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); //Select EndTime Thread.Sleep(1000); EndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); //Select Skill Trade Credit.Click(); Thread.Sleep(500); if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange") { RequiredSkills.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); CreditAmount.SendKeys(Keys.Enter); //Enter credit amount // CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); //Select the stats // StatusActive.Click(); //Thread.Sleep(500); if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Hidden") { StatusHidden.Click(); } //Save the Share Skill Thread.Sleep(500); SaveShareSkills.Click(); Thread.Sleep(500); //Verify if newShared skill is saved Thread.Sleep(3000); string ShareSkillSucess = Global.GlobalDefinitions.driver.FindElement(By.CssSelector("#listing-management-section > div:nth-child(3) > div:nth-child(2) > table > thead > tr > th:nth-child(1)")).Text; if (ShareSkillSucess == "Image") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Saved Skill Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Saving Skill Unsuccessful"); } } }
//Add share skill details internal void EnterShareSkill() { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); try { #region Navigate to Share Skills Page //Click on Share skill button GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "LinkText", "Share Skill", 10000); ShareSkillButton.Click(); #endregion #region Enter Title //Enter the Title in textbox GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "Name", "title", 10000); Title.Click(); Title.Clear(); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); #endregion #region Enter Description //Enter the Description in textbox GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "Name", "description", 10000); Description.Click(); Description.Clear(); Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); #endregion #region Category Drop Down //Select catagory from drop down GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "Name", "categoryId", 10000); CategoryDropDown.Click(); new SelectElement(CategoryDropDown).SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select catagory from drop down GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "Name", "subcategoryId", 10000); SubCategoryDropDown.Click(); new SelectElement(SubCategoryDropDown).SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); #endregion #region Tags //Enter Tag names in textbox GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//input[@value='']", 10000); Tags.Click(); Tags.Clear(); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); #endregion #region Service Type Selection //Select service type if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", 10000); ServiceTypeOptions.Click(); ServicetypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", 10000); ServiceTypeOptions.Click(); ServicetypeOneOff.Click(); } #endregion #region Select Location Type //Select the Location Type if (GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") == "On-site") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", 10000); LocationTypeOption.Click(); LocationSelOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") == "Online") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", 10000); LocationTypeOption.Click(); LocationSelOnline.Click(); } #endregion #region Select Available Dates from Calendar //Add start date StartDateDropDown.Click(); // StartDateDropDown.Clear(); StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Add End date EndDateDropDown.Click(); //EndDateDropDown.Clear(); EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Select available days GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//body/div/div/div[@id='service-listing-section']/div[@class='ui container']/div[@class='listing']/form[@class='ui form']/div[7]/div[2]/div[1]", 10000); Days.Click(); Mon.Click(); Tue.Click(); Wed.Click(); Thurs.Click(); //Select start time and enter the time GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[3]/div[2]/input", 10000); StartTimeM.Click(); StartTimeDropDownM.Click(); StartTimeM.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[4]/div[2]/input", 10000); StartTimeT.Click(); StartTimeDropDownT.Click(); StartTimeT.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[5]/div[2]/input", 10000); StartTimeW.Click(); StartTimeDropDownW.Click(); StartTimeW.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[6]/div[2]/input", 10000); StartTimeTh.Click(); StartTimeDropDownTh.Click(); StartTimeTh.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("hh:mmtt")); //Select end time from box GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[3]/div[3]/input", 10000); EndTimeM.Click(); EndTimeDropDownM.Click(); EndTimeM.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[4]/div[3]/input", 10000); EndTimeT.Click(); EndTimeDropDownT.Click(); EndTimeT.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[5]/div[3]/input", 10000); EndTimeW.Click(); EndTimeDropDownW.Click(); EndTimeW.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("hh:mmtt")); GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[6]/div[3]/input", 10000); EndTimeTh.Click(); EndTimeDropDownTh.Click(); EndTimeTh.SendKeys(DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("hh:mmtt")); Thread.Sleep(1000); #endregion #region Select Skill Trade //Click on Skill trade option if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == "Skill-Exchange") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[8]/div[@class='twelve wide column']/div/div[@class='field']", 10000); SkillTradeOption.Click(); //Add Skill exchange tag GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[8]/div[4]/div/div/div/div/div/input", 10000); SkillExchange.Click(); SkillExchange.Clear(); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == "Credit") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[8]/div[@class='twelve wide column']/div/div[@class='field']", 10000); SkillTradeOption.Click(); CreditBtn.Click(); //Addcredit amount GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[8]/div[4]/div/div/input", 10000); CreditAmount.Click(); CreditAmount.Clear(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } #endregion #region Add Work Sample FileUpload.Click(); AutoItX3 autoIt = new AutoItX3(); AutoItX.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open"); Thread.Sleep(2000); var SampleWorkPath = MarsResource.SampleWorkPath; autoIt.Send(Path.GetFullPath(SampleWorkPath)); Thread.Sleep(2000); autoIt.Send("{Enter}"); Thread.Sleep(2000); #endregion #region Select User Status //Select option Active or Hidden if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", 10000); ActiveOption.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", 10000); ActiveOption.Click(); HiddenOpt.Click(); } #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { GlobalDefinitions.WaitForElementVisibility(GlobalDefinitions.driver, "XPath", "//input[@value='Save']", 10000); Save.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { Cancel.Click(); } #endregion } catch (Exception ex) { Assert.Fail("Test failed to enter Skill details", ex.Message); } }
internal void EditManageListings() { Thread.Sleep(500); //Clicking the manage listing button manageListingsLink.Click(); Thread.Sleep(500); //Clicking edit button(edit is acting as adding option only) edit.Click(); Thread.Sleep(500); //Populating with excel data GlobalDefinitions.ExcelLib.PopulateInCollection(@"MarsFramework\ExcelData\TestDataManageListings.xlsx", "ManageListings"); //Enetering Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Entering Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Selecting Category SelectElement Category = new SelectElement(CategoryDropDown); Category.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Slecting Subcategory SelectElement SubCategory = new SelectElement(SubCategoryDropDown); SubCategory.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Entering the Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + "\n"); //Clicking the Service type ServiceTypeOptions.Click(); //Clicking the Type option LocationTypeOption.Click(); //Handling the Date and time Thread.Sleep(500); StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Sending start date data Thread.Sleep(500); EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //sending end date data Thread.Sleep(1500); //Looping for the targeted day, timings and corresponding check box for (int i = 0; i <= 9; i++) { var checkBox = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (2 + i) + "]/div[1]/div/input")); var dayName = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (2 + i) + "]/div[1]/div/label")); var startTime = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (2 + i) + "]/div[2]/input")); var endTime = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (2 + i) + "]/div[3]/input")); if (GlobalDefinitions.ExcelLib.ReadData(2, "Selectday") == dayName.Text) { Thread.Sleep(500); //Clicking checkbox checkBox.Click(); Thread.Sleep(500); //Entering particular start timing in targeted day startTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); Thread.Sleep(500); //Entering particular End timings in targeted day endTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); break; } } Thread.Sleep(500); //Clicking Skills Exchange SkillTradeOptionSkillExchange.Click(); Thread.Sleep(500); //Enetering Skill Exchnge Tag SkillExchangeTags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchange") + "\n"); Thread.Sleep(500); //Clicking Credit SkillTradeOptionCredit.Click(); Thread.Sleep(500); //Entering Credit CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); //Uploading File Thread.Sleep(500); workSamples.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinActivate("Open"); Thread.Sleep(3000); autoIt.Send(Base.FileToUploadPath); Thread.Sleep(2000); autoIt.Send("{ENTER}"); //Clicking Active option ActiveOption.Click(); //Saving the new/ updated Manage skills Save.Click(); //Asserts Thread.Sleep(3000); var DescriptionAssert = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[4]")).Text; NUnit.Framework.Assert.That(DescriptionAssert, Is.EqualTo(GlobalDefinitions.ExcelLib.ReadData(2, "Description"))); }
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"); }
internal void EnterShareSkill() { try { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); //Click on Share Skill button ShareSkillButton.Click(); //Enter the Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Enter the Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Choose the Category SelectElement Category = new SelectElement(CategoryDropDown); Category.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Choose the Sub Category SelectElement SubCategory = new SelectElement(SubCategoryDropDown); SubCategory.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Enter the tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); //Click the Enter button Tags.SendKeys(Keys.Enter); //Click on Service type radio button if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == ServiceTypeOptionsText1.Text) { if (!ServiceTypeOptions1.Selected) { ServiceTypeOptions1.Click(); } } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == ServiceTypeOptionsText2.Text) { if (!ServiceTypeOptions2.Selected) { GlobalDefinitions.wait(5000); ServiceTypeOptions2.Click(); } } //Click on Location type radio button if (GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") == LocationTypeOptionsText1.Text) { GlobalDefinitions.wait(5000); if (!LocationTypeOptions1.Selected) { GlobalDefinitions.wait(5000); LocationTypeOptions1.Click(); } } else if (GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") == LocationTypeOptionsText2.Text) { if (!LocationTypeOptions2.Selected) { GlobalDefinitions.wait(5000); LocationTypeOptions2.Click(); } } #region radio buttons //Click on Skill trade radio button if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == SkillTradeOptionText1.Text) { if (!SkillTradeOption1.Selected) { SkillTradeOption1.Click(); } //Enter the tag name in Skill exchange and press Enter key SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); //} } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade") == SkillTradeOptionText2.Text) { SkillTradeOption2.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Click on Active radio buttons if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == ActiveOptionText1.Text) { if (!ActiveOption1.Selected) { ActiveOption1.Click(); } } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == ActiveOptionText2.Text) { ActiveOption2.Click(); } #endregion //Click on File Upload FileUpload.Click(); //Using AutoIt // AutoItx Autoit = new AutoItx(); AutoItX.WinActivate("Open"); AutoItX.Sleep(500); AutoItX.Send(@"C:\Users\anvil\Desktop\TestAnalyst.txt"); //GlobalDefinitions.wait(1200); AutoItX.Send("{ENTER}"); //StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); GlobalDefinitions.wait(10000); Save.Click(); GlobalDefinitions.wait(10000); Assert.Pass("Successfully Service Listing is Added"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Listings() { GlobalDefinitions.Wait(); ManageListingsLink.Click(); //Checking the right page Assert.AreEqual("ListingManagement", GlobalDefinitions.driver.Title); Base.test = Base.extent.StartTest("On Share Manage Listing page"); edit.Click(); //Populate the Excel Sheet Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); Title.SendKeys(ExcelLib.ReadData(3, "Title")); GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(3, "Title"), "Title"); Description.SendKeys(ExcelLib.ReadData(3, "Description")); GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(3, "Description"), "Description"); CategoryDropDown.SendKeys(ExcelLib.ReadData(3, "Category")); SubCategoryDropDown.SendKeys(ExcelLib.ReadData(3, "SubCategory")); TxtTags.SendKeys(ExcelLib.ReadData(3, "Tags")); TxtTags.SendKeys(Keys.Enter); IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//div[5]//div[2]//div[1]//div[2]//div[1]//input[1]")); ServiceTypeOptions.Click(); IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[2]//div[1]//input[1]")); LocationTypeOption.Click(); StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate")); EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate")); for (int i = 2; i < 9; i++) { for (int j = 2; j < 9; j++) { IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input")); IWebElement EndTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input")); if (i == 2 && j == 2) { GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0230PM"); StartTime.SendKeys(Keys.Tab); EndTime.SendKeys("3052PM"); } if (i == 3 && j == 3) { GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0530PM"); EndTime.SendKeys("0856PM"); } } } IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]")); if (!credit.Selected) { credit.Click(); CreditAmount.SendKeys("9"); } WorkSample.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.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt"); //autoIt autoIt.Send("{ENTER}"); autoIt.Sleep(1000); IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']")); ActiveOption.Click(); GlobalDefinitions.Wait(); Save.Click(); GlobalDefinitions.Wait(); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills edited succesfully"); string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[2]")).Text; Assert.AreEqual(searchInput1, ExcelLib.ReadData(3, "Category")); string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[3]")).Text; Assert.AreEqual(searchInput2, ExcelLib.ReadData(3, "Title")); string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[5]")).Text; Assert.AreEqual(searchInput3, ExcelLib.ReadData(3, "ServiceType")); }
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")); }
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 EditSkill() { #region populate excel //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(MarsResources.ExcelPath, "Managelisting"); #endregion #region Enter Title Title.WaitForElementClickable(Global.Base.driver, 60); //Enter the data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title")); #endregion #region Enter Description //Enter the data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription")); #endregion #region Category Drop Down // Click on Category Dropdown Category.Click(); Thread.Sleep(1000); // Select Category from Category Drop Down var selectElement = new SelectElement(Category); selectElement.SelectByIndex(3); // Click on Sub-Category Dropdown SubCategory.Click(); Thread.Sleep(1000); //Select Sub-Category from the Drop Down var SelectElement1 = new SelectElement(SubCategory); SelectElement1.SelectByIndex(4); #endregion #region Tags // Eneter Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName")); Tags.SendKeys(Keys.Enter); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "TagName")); Tags.SendKeys(Keys.Enter); #endregion #region Service Type Selection // Service Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { ServiceTypeOnOff.Click(); } #endregion #region Select Location Type // Location Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site") { LocationTypeOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online") { LocationTypeOnline.Click(); } #endregion #region Select Available Dates from Calendar // Select Start Date //StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); // Select End Date EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); // select available days and start time and End time for (int i = 2; i < 9; i++) { for (int j = 2; j < 9; j++) { for (int k = 2; k < 9; k++) { IWebElement SatrtTime = driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input")); IWebElement EndTime = driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input")); IWebElement AvailableDays = driver.FindElement(By.XPath("//div[7]/div[2]/div/div[" + k + "]/div[1]/div/input")); if (i == 2 && j == 2 && k == 2) { AvailableDays.Click(); SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartTime")); EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndTime")); } if (i == 3 && j == 3 && k == 3) { AvailableDays.Click(); SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "StartTime")); EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "EndTime")); } if (i == 4 && j == 4 && k == 4) { AvailableDays.Click(); SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "StartTime")); EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "EndTime")); } } } } #endregion #region Select Skill Trade // Select Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange") { SkillExchange.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } #endregion #region Select User Status // Select User Status if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { StatusHidden.Click(); } #endregion #region Add Work Sample //Click on Work sample WorkSample.Click(); //AutoIT AutoItX3 AutoIt = new AutoItX3(); AutoIt.WinActivate("Open"); Thread.Sleep(3000); AutoIt.Send(@"A:\AdvanceTask\StandardTask\TW.docx"); Thread.Sleep(2000); AutoIt.Send("{ENTER}"); #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { Save.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { Cancel.Click(); } #endregion Thread.Sleep(3000); #region Check whether New skill updated sucessfully //String expectedValue = GlobalDefinitions.ExcelLib.ReadData(2, "title"); // Validate view listing through Page title String actualTitle = driver.Title; // Assert.AreEqual(actualTitle, "ListingManagement"); if (actualTitle == "ListingManagement") { Assert.IsTrue(true); Global.Base.test.Log(Status.Pass, "Shared Skill Successful"); SaveScreenShotClass.SaveScreenshot(driver, "AddShareSkill"); } else { Console.WriteLine("Test failed"); SaveScreenShotClass.SaveScreenshot(driver, "FailedAddShareSkill"); Global.Base.test.Log(Status.Fail, "Share Skill Unsuccessful"); } #endregion }
public void EditSkill() { #region populate excel //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(MarsResources.ExcelPath, "Managelisting"); #endregion #region Enter Title Title.WaitForElementClickable(Global.Base.driver, 60); //Enter the data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title")); #endregion #region Enter Description //Enter the data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription")); #endregion #region Category Drop Down // Click on Category Dropdown Category.Click(); Thread.Sleep(1000); // Select Category from Category Drop Down var selectElement = new SelectElement(Category); selectElement.SelectByIndex(3); // Click on Sub-Category Dropdown SubCategory.Click(); Thread.Sleep(1000); //Select Sub-Category from the Drop Down var SelectElement1 = new SelectElement(SubCategory); SelectElement1.SelectByIndex(4); #endregion #region Tags // Eneter Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName")); Tags.SendKeys(Keys.Enter); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "TagName")); Tags.SendKeys(Keys.Enter); #endregion #region Service Type Selection // Service Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { ServiceTypeOnOff.Click(); } #endregion #region Select Location Type // Location Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site") { LocationTypeOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online") { LocationTypeOnline.Click(); } #endregion #region Select Available Dates from Calendar // Select Start Date //StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); // Select End Date EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); // select available days and start time and End time IList <IWebElement> Sttim = driver.FindElements(By.Name("StartTime")); IList <IWebElement> Edtim = driver.FindElements(By.Name("EndTime")); IList <IWebElement> Ckbx = driver.FindElements(By.XPath("(//input[@name='Available'])")); if (Ckbx.Count != 0) { //Selecting checkboxes for days from Monday to Friday for (int i = 1; i <= Ckbx.Count - 2; i++) { //Verify whether checkbox is not selected if (!Ckbx.ElementAt(i).Selected) { Ckbx.ElementAt(i).Click(); } //Validating the Count Sttim.ElementAt(i).SendKeys(GlobalDefinitions.ExcelLib.ReadData(i + 1, "StartTime")); Thread.Sleep(2000); Edtim.ElementAt(i).SendKeys(GlobalDefinitions.ExcelLib.ReadData(i + 1, "EndTime")); Thread.Sleep(2000); } } #endregion #region Select Skill Trade // Select Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange") { SkillExchange.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit") { Credit.Click(); CreditAmount.Click(); string input = GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange"); int result = Int32.Parse(input); if (result >= 10) { SaveScreenShotClass.SaveScreenshot(driver, "More than One digit not Possible"); Global.Base.test.Log(Status.Fail, "Two Digit not Added "); Assert.Fail("Entering more than One digit not Possible"); } else { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } } #endregion #region Select User Status // Select User Status if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { StatusHidden.Click(); } #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { Save.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { Cancel.Click(); } #endregion Thread.Sleep(3000); #region Check whether New skill updated sucessfully //String expectedValue = GlobalDefinitions.ExcelLib.ReadData(2, "title"); // Validate view listing through Page title String actualTitle = driver.Title; // Assert.AreEqual(actualTitle, "ListingManagement"); if (actualTitle == "ListingManagement") { Assert.IsTrue(true); Global.Base.test.Log(Status.Pass, "Shared Skill Successful"); SaveScreenShotClass.SaveScreenshot(driver, "AddShareSkill"); } else { Console.WriteLine("Test failed"); SaveScreenShotClass.SaveScreenshot(driver, "FailedAddShareSkill"); Global.Base.test.Log(Status.Fail, "Share Skill Unsuccessful"); } #endregion }
//[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); } }
internal void EnterShareSkill() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(AppDomain.CurrentDomain.BaseDirectory.Replace(@"MarsFramework\bin\Debug\", @"MarsFramework\ExcelData\TestDataShareSkill.xlsx"), "ShareSkill"); //wait for element to appear Global.GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.Driver, By.LinkText("Share Skill"), (20)); //Click on the share skill button ShareSkillButton.Click(); //Click on the title field Global.GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.Driver, By.Name("title"), (20)); Title.Click(); //Type on the title field Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(1, "Title")); //Click on the description Global.GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.Driver, By.Name("description"), (20)); Description.Click(); //Type on the Description Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(1, "Description")); //Click on category dropdown CategoryDropDown.Click(); //Choose an option from category dropdown CategoryDropDown.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(1, "Category") + Keys.Enter); //Click on sub category SubCategoryDropDown.Click(); //Choose an option from subcategory dropdown SubCategoryDropDown.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(1, "SubCategory") + Keys.Enter); //Click on Tags Field Tags.Click(); //Type on the Tags Field then press Enter Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(1, "Tags") + Keys.Enter); //Click and choose an option for Service type ServiceTypeOptions.Click(); //Click and Choose an option for location type LocationTypeOption.Click(); //click on a skill trade option skill exchange SkillTradeOptionSkillExchange.Click(); //Click on skill exchange SkillExchange.Click(); //Type and add a tag SkillExchange.SendKeys("Test tag" + Keys.Enter); //click on a skill trade option credit SkillTradeOptionCredit.Click(); //Click on credit amount CreditAmount.Click(); //type and add a credit amount CreditAmount.SendKeys("2" + Keys.Enter); //Click an option on Active ActiveOption.Click(); //Save the skill Save.Click(); Thread.Sleep(2000); }
internal void EditShareSkill() { //Populate the Excel sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ShareSkill"); int excelRowToRead = 3; Title.Clear(); Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Title")); //Click on Description Description.Clear(); Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Description")); //Select A Category CategoryDropDown.Click(); String categoryValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Category"); IList <IWebElement> CategoriesDropDownList = CategoryDropDown.FindElements(By.XPath("//option")); int DpListCount = CategoriesDropDownList.Count; for (int i = 0; i < DpListCount; i++) { if (CategoriesDropDownList[i].Text == categoryValue) { CategoriesDropDownList[i].Click(); } } //Select Sub Category Thread.Sleep(1000); IWebElement SubCategorySelection = Global.GlobalDefinitions.driver.FindElement(By.Name("subcategoryId")); SubCategorySelection.Click(); String SubCategoryValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SubCategory"); IList <IWebElement> SubCategoriesDropDownList = SubCategorySelection.FindElements(By.XPath("//option")); int SbDpListCount = SubCategoriesDropDownList.Count; for (int i = 0; i < SbDpListCount; i++) { if (SubCategoriesDropDownList[i].Text == SubCategoryValue) { SubCategoriesDropDownList[i].Click(); } } //Clear and Add Tags IWebElement tagsInputBox = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[4]/div[2]/div")); IList <IWebElement> RemoveButtons = tagsInputBox.FindElements(By.ClassName("ReactTags__remove")); foreach (IWebElement element in RemoveButtons) { element.Click(); } Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Tag")); Tags.SendKeys(Keys.Enter); //Select Service Type String ServiceType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Service Type"); if (ServiceType.Equals("Hourly basis Service")) { HourlyServiceType.Click(); } else if (ServiceType.Equals("One-off Service")) { OneOffServiceType.Click(); } //Select Location Type String LocatioType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Location Type"); if (LocatioType.Equals("On-site")) { OnSiteLocationType.Click(); } else if (OnSiteLocationType.Equals("Online")) { OnlineLocationType.Click(); } //Select Available Start Date IWebElement AvailableStartDateInput = AvailabilityForm.FindElement(By.Name("startDate")); AvailableStartDateInput.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableStartDate")); //Select Available End Date IWebElement AvailableEndDateInput = AvailabilityForm.FindElement(By.Name("endDate")); AvailableEndDateInput.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableEndDate")); String[] WeekDays = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; //Cleared Selected Checkboxes IList <IWebElement> AvailableCheckBoxes = AvailabilityForm.FindElements(By.Name("Available")); foreach (IWebElement element in AvailableCheckBoxes) { if (element.Selected) { element.Click(); } } //Select Check boxes based on data String AvailableDaysValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableDays"); IList <String> AvailableDays = AvailableDaysValue.Split(','); for (int i = 0; i < WeekDays.Count(); i++) { if (AvailableDays.Contains(WeekDays[i])) { AvailableCheckBoxes[i].Click(); } } //Set Start times IList <IWebElement> AvailableStartTimeInputs = AvailabilityForm.FindElements(By.Name("StartTime")); String AvailableStartTimesValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableStartTimes"); IList <String> AvailableStartTimes = AvailableStartTimesValue.Split(','); for (int i = 0; i < AvailableStartTimes.Count(); i++) { IList <String> startTimeInfo = AvailableStartTimes[i].Split(':'); String startTimeDay = startTimeInfo[0]; String startTimeValue = startTimeInfo[1]; int indexOfDay = Array.IndexOf(WeekDays, startTimeDay); AvailableStartTimeInputs[indexOfDay].SendKeys(startTimeValue); } //Set End times IList <IWebElement> AvailableEndTimeInputs = AvailabilityForm.FindElements(By.Name("EndTime")); String AvailableEndTimesValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableEndTimes"); IList <String> AvailableEndTimes = AvailableEndTimesValue.Split(','); for (int i = 0; i < AvailableEndTimes.Count(); i++) { IList <String> endTimeInfo = AvailableEndTimes[i].Split(':'); String endTimeDay = endTimeInfo[0]; String endTimeValue = endTimeInfo[1]; int indexOfDay = Array.IndexOf(WeekDays, endTimeDay); AvailableEndTimeInputs[indexOfDay].SendKeys(endTimeValue); } //Select Skill Exchange Type String SkillTradeType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SkillTradeType"); if (SkillTradeType.Equals("Skill-exchange")) { SkillExchangeType.Click(); //Clear and Add Tags IWebElement SkillTagsInputBox = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[8]/div[4]/div/div")); IList <IWebElement> CrossButtons = SkillTagsInputBox.FindElements(By.ClassName("ReactTags__remove")); foreach (IWebElement element in CrossButtons) { element.Click(); } SkillExchangeTag.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SkillExchangeTab")); SkillExchangeTag.SendKeys(Keys.Enter); } else if (SkillTradeType.Equals("Credit")) { CreditsType.Click(); CreditAmount.Clear(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "CreditsAmount")); } //Select Active Status Button String ActiveType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "ActiveType"); if (SkillTradeType.Equals("Active")) { ActiveButton.Click(); } else if (SkillTradeType.Equals("Hidden")) { HiddenButton.Click(); } //Click on Save Button SaveButton.Click(); Thread.Sleep(3000); //Verify IWebElement listingTable = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table")); IList <IWebElement> tableRows = listingTable.FindElements(By.TagName("tr")); Boolean isListingEdited = false; for (int i = 0; i <= tableRows.Count; i++) { IWebElement row = tableRows[i]; if (row.Text.Contains(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Title")) && row.Text.Contains(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Description"))) { isListingEdited = true; break; } } if (isListingEdited == true) { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Edit Skill test Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edit Skill test Failed"); } }
//Edit the Existing share Skill internal void EditShareSkillData() { Extension.WaitForElementDisplayed(Driver, By.Name("title"), 5); //Clear the Title Title.Clear(); //Enter the Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Clear the Description Description.Clear(); //Enter the Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select Category CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select Sub-Category GlobalDefinitions.SelectDropDown(SubCategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Clear the Entered tag foreach (IWebElement removeTag in RemoveTags) { removeTag.Click(); } //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")); //Clear the Available days data int DaysRows = Days.FindElements(By.Name("Available")).Count; for (int i = 1; i <= DaysRows; i++) { if (Days.FindElements(By.Name("Available"))[i - 1].Selected) { Days.FindElements(By.Name("Available"))[i - 1].Click(); Days.FindElements(By.Name("StartTime"))[i - 1].SendKeys(Keys.Delete); Days.FindElements(By.Name("EndTime"))[i - 1].SendKeys(Keys.Delete); } } //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.Clear(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Select Active radio GlobalDefinitions.SelectRadioButton(ActiveOption, GlobalDefinitions.ExcelLib.ReadData(2, "Active"), By.Name("isActive")); }
public void AddNewSkill() { #region Navigate to Share Skills Page // Click on Share Skills Page ShareSkill.WaitForElementClickable(Global.Base.driver, 60); ShareSkill.Click(); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(MarsResources.ExcelPath, "ShareSkills"); #endregion #region Enter Title Title.WaitForElementClickable(Global.Base.driver, 60); //Enter the data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title")); #endregion #region Enter Description //Enter the data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription")); #endregion #region Category Drop Down // Click on Category Dropdown Category.Click(); // Select Category from Category Drop Down var SelectElement = new SelectElement(Category); SelectElement.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "category"))); // Click on Sub-Category Dropdown SubCategory.Click(); //Select Sub-Category from the Drop Down var SelectElement1 = new SelectElement(SubCategory); SelectElement1.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "subcategory"))); #endregion #region Tags // Eneter Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName")); Tags.SendKeys(Keys.Enter); Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "TagName")); Tags.SendKeys(Keys.Enter); #endregion #region Service Type Selection // Service Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { ServiceTypeOnOff.Click(); } #endregion #region Select Location Type // Location Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site") { LocationTypeOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online") { LocationTypeOnline.Click(); } #endregion #region Select Available Dates from Calendar // Select Start Date //StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); // Select End Date EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); // select available days and start time and End time // select available days and start time and End time Thread.Sleep(3000); IList <IWebElement> Sttim = driver.FindElements(By.Name("StartTime")); IList <IWebElement> Edtim = driver.FindElements(By.Name("EndTime")); //Driver.FindElements(By.Name("EndTime")); IList <IWebElement> Ckbx = driver.FindElements(By.XPath("(//input[@name='Available'])")); if (Ckbx.Count != 0) { //Selecting checkboxes for days from Monday to Friday for (int i = 1; i <= Ckbx.Count - 2; i++) { //Verify whether checkbox is not selected if (!Ckbx.ElementAt(i).Selected) { Ckbx.ElementAt(i).Click(); } Console.WriteLine(driver); //Validating the Count Sttim.ElementAt(i).SendKeys(GlobalDefinitions.ExcelLib.ReadData(i + 1, "StartTime")); // Sttim.ElementAt(i).SendKeys("10:00"); /* var Svalue = Sttim.ElementAt(i).GetAttribute("value"); * Console.WriteLine(Svalue); * Sttim.ElementAt(i).SendKeys(Svalue);*/ Thread.Sleep(2000); // Sttim.ElementAt(i).Clear(); Edtim.ElementAt(i).SendKeys(GlobalDefinitions.ExcelLib.ReadData(i + 1, "EndTime")); // Edtim.ElementAt(i).SendKeys("18:00"); Thread.Sleep(2000); } } #endregion #region Select Skill Trade // Select Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange") { SkillExchange.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } #endregion #region Select User Status // Select User Status if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { StatusHidden.Click(); } #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { Save.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { Cancel.Click(); } #endregion Thread.Sleep(3000); #region Check whether New skill created sucessfully //String expectedValue = GlobalDefinitions.ExcelLib.ReadData(2, "title"); String actualTitle = driver.Title; //string ShareSkillSucess = Driver.FindElement(By.TagName("h2")).Text; if (actualTitle == "ListingManagement") { Assert.IsTrue(true); Global.Base.test.Log(Status.Pass, "Shared Skill Successful"); SaveScreenShotClass.SaveScreenshot(driver, "AddShareSkill"); } else { Console.WriteLine("Test failed"); SaveScreenShotClass.SaveScreenshot(driver, "FailedAddShareSkill"); Global.Base.test.Log(Status.Fail, "Share Skill Unsuccessful"); } #endregion }
internal void EditShareSkill() { //Thread.Sleep(3000); GlobalDefinitions.Wait(3000); ManagementListingBtn.Click(); //Thread.Sleep(2000); GlobalDefinitions.Wait(2000); GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "EditShareSkill"); try { //Thread.Sleep(1000); GlobalDefinitions.Wait(1000); var table = _driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody")); //table var manageListRow = table.FindElements(By.TagName("tr")).ToList(); //all rows picked var isFound = false; // var rows = _driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr")); //each row and coloum for (int i = 1; i <= manageListRow.Count; i++) { var row = _driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]")); //each row and coloum var columnList = row.FindElements(By.TagName("td")).ToList(); //all coloum for (int j = 1; j <= columnList.Count; j++) { var oldManageList = _driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[" + j + "]")); //each row and coloum //click on edit button with specific row and column if (oldManageList.Text == "Code") { isFound = true; _driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[8]/div/button[2]/i")).Click(); //edit button break; } } if (isFound) { break; } } if (isFound) { Thread.Sleep(1000); //Add Title {edit value update from (Code)} EditTitle.Clear(); EditTitle.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EditTitle")); //Thread.Sleep(1000); GlobalDefinitions.Wait(1000); //Add Description EditDescrp.Clear(); EditDescrp.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Thread.Sleep(1000); GlobalDefinitions.Wait(1000); //Service type OneOff.Click(); //Thread.Sleep(1000); GlobalDefinitions.Wait(1000); //Skill Trade EditCredit.Click(); CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "CreditAmount")); //Thread.Sleep(1000); GlobalDefinitions.Wait(1000); Save.Click(); } else { Console.WriteLine("Test Fail, Edit un-successful"); } } catch (Exception ex) { throw; } }
public void AddNewSkill() { #region Navigate to Share Skills Page // Click on Share Skills Page ShareSkill.WaitForElementClickable(_driver, 60); ShareSkill.Click(); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills"); #endregion #region Enter Title Title.WaitForElementClickable(_driver, 60); //Enter the data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title")); #endregion #region Enter Description //Enter the data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription")); #endregion #region Category Drop Down // Click on Category Dropdown Category.Click(); // Select Category from Category Drop Down var SelectElement = new SelectElement(Category); SelectElement.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "category"))); // Click on Sub-Category Dropdown SubCategory.Click(); //Select Sub-Category from the Drop Down var SelectElement1 = new SelectElement(SubCategory); SelectElement1.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "subcategory"))); #endregion #region Tags // Eneter Tag Tag.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName")); Tag.SendKeys(Keys.Enter); #endregion #region Service Type Selection // Service Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { ServiceTypeOnOff.Click(); } #endregion #region Select Location Type // Location Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site") { LocationTypeOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online") { LocationTypeOnline.Click(); } #endregion #region Select Available Dates from Calendar // Select Start Date StartDate.Click(); // Select End Date EndDate.Click(); #endregion #region Select Skill Trade // Select Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange") { RequiredSkills.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } #endregion #region Select User Status // Select User Status if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { StatusHidden.Click(); } #endregion #region Add Work Sample //Work Sample upload button path IWebElement upload = _driver.FindElement(By.XPath("//*[@id='selectFile']")); // Uploading File path var GetCurrentDirectory = Directory.GetCurrentDirectory(); String path = GetCurrentDirectory + @"\MarsFramework\Upload Files\Samplework.txt"; upload.SendKeys(path); #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { SaveShareSkills.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { CancelShareSkills.Click(); } #endregion #region Check whether New skill created sucessfully string ShareSkillSucess = _driver.FindElement(By.LinkText("Manage Listings")).Text; if (ShareSkillSucess == "Manage Listings") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Shared Skill Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Share Skill Unsuccessful"); } #endregion }
internal void EnterShareSkill() { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPathShareSkill, "ShareSkill"); //Waiting for Profile page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.LinkText("Share Skill"), 10); //Click on Share Skill button ShareSkillButton.Click(); //Waiting for Share Skill page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.Name("title"), 10); //Enter Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title") + TimeStamp); //Enter Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select Category from DropDown CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select SubCategory from DropDown SubCategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + Keys.Enter); //Select ServiceType from Option switch ((GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"))) { case "Hourly basis service": //Select Hourly basis service from options ServiceTypeOptions[0].Click(); break; case "One-off service": //Select One-off service from options ServiceTypeOptions[1].Click(); break; } //Select LocationType from Option switch ((GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"))) { case "On-site": //Select On-site from location options LocationTypeOption[0].Click(); break; case "Online": //Select Online from location options LocationTypeOption[1].Click(); break; } //Enter StartDate from DropDown StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Enter EndDate from DropDown EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Select Days and enter Start and End time if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sun") { //Select Sunday Days[0].Click(); //Enter StartTime from DropDown StartTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[0].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Mon") { //Select Monday Days[1].Click(); //Enter StartTime from DropDown StartTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Tue") { //Select Tuesday Days[2].Click(); //Enter StartTime from DropDown StartTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Wed") { //Select Wednesday Days[3].Click(); //Enter StartTime from DropDown StartTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Thu") { //Select Thursday Days[4].Click(); //Enter StartTime from DropDown StartTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Fri") { //Select Friday Days[5].Click(); //Enter StartTime from DropDown StartTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sat") { //Select Saturday Days[6].Click(); //Enter StartTime from DropDown StartTimeDropDown[7].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } //Select Skill Trade from options if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Skill-Exchange") { //Select Skill-exchange from available options SkillTradeOption[0].Click(); //Enter SkillExchange SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + Keys.Enter); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Credit") { //Select Credit from available options SkillTradeOption[1].Click(); //Enter Credit Amount CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Select ActiveOption switch ((GlobalDefinitions.ExcelLib.ReadData(2, "Active"))) { case "Active": //Select Active status ActiveOption[0].Click(); break; case "Hidden": //Select Hidden status ActiveOption[1].Click(); break; } //Click on work sample file add icon FileAdd.Click(); //Add work sample file using AutoIT AutoItX.WinWait("[CLASS:#32770]", "", 30); Thread.Sleep(3000); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", @"C:\Study\IndustryConnect\git\ProjectMarsTestAutomationHybridFramework\MarsFramework\testFile.txt"); Thread.Sleep(3000); AutoItX.ControlClick("Open", "", "Button1"); //Click on Save button Save.Click(); //Waiting for Manage Listing page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//table[1]/tbody[1]"), 10); }
internal void EnterShareSkill() { int rows; rows = GlobalDefinitions.ExcelLib.NumberofRows(@"C:\Users\JIJI\source\repos\marsframework-master\MarsFramework\ExcelData\TestDataShareSkill.xlsx", "ShareSkill"); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(@"C:\Users\JIJI\source\repos\marsframework-master\MarsFramework\ExcelData\TestDataShareSkill.xlsx", "ShareSkill"); Thread.Sleep(1500); for (int i = 2; i <= rows + 1; i++) { Thread.Sleep(1500); //Click on Share Skill ShareSkillButton.Click(); //Enter Title Thread.Sleep(3500); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Title")); //Enter Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Description")); //Enter Category CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Category")); //Enter Sub-Category SubCategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "SubCategory")); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Tags")); Tags.SendKeys(Keys.Enter); //Enter ServiceType String Service = GlobalDefinitions.ExcelLib.ReadData(i, "ServiceType"); if (Service == "One-off service") { ServiceTypeOptions.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[5] / div[2] / div[1] / div[2] / div / input")).Click(); } else { ServiceTypeOptions.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[5]/div[2]/div[1]/div[1]/div/input")).Click(); } //Enter LocationType String LocationType = GlobalDefinitions.ExcelLib.ReadData(i, "LocationType"); if (LocationType == "On-site") { LocationTypeOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[6]/div[2]/div/div[1]/div/input")).Click(); } else { LocationTypeOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[6]/div[2]/div/div[2]/div/input")).Click(); } //Enter Startdate //StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate").ToString()); //Enter Enddate // EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Enter Selectday // String Day=GlobalDefinitions.ExcelLib.ReadData(2, "Selectday"); //if(Day== "Sun") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[2]/div[1]/div/input")).Click(); //} //else if(Day=="Mon") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[3]/div[1]/div/input")).Click(); // } //else if (Day == "Tue") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[4]/div[1]/div/input")).Click(); //} //else if (Day == "Wed") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[5]/div[1]/div/input")).Click(); //} //else if (Day == "Thu") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[6]/div[1]/div/input")).Click(); //} //else if (Day == "Fri") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[7]/div[1]/div/input")).Click(); //} //else if (Day == "Sat") //{ // Days.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div[1]/div[8]/div[1]/div/input")).Click(); //} //Enter Starttime // StartTimeDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Starttime")); //Enter Endtime // EndTimeDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Endtime")); //Enter SkillTrade string SkillTrade = GlobalDefinitions.ExcelLib.ReadData(i, "SkillTrade"); if (SkillTrade == "Skill-Exchange") { SkillTradeOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[8]/div[2]/div/div[1]/div/label")).Click(); } else { SkillTradeOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[8]/div[2]/div/div[2]/div/label")).Click(); } //Enter Skill-Exchange SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); //Enter Credit if (SkillExchange.Text == "Credit") { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(i, "Credit")); } ////Work Sample Driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[9]/div/div[2]/section/div/label/div/span/i")).Click(); AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Open"); Thread.Sleep(1500); autoit.ControlSetText("Open", "", "Edit1", StrSendText); autoit.ControlClick("Open", "", "Button1"); //Enter Active string Active = GlobalDefinitions.ExcelLib.ReadData(i, "Active"); if (Active == "Active") { ActiveOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[10]/div[2]/div/div[1]/div/input")).Click(); } else { ActiveOption.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[10]/div[2]/div/div[2]/div/input")).Click(); } //Click on save Save.Click(); Thread.Sleep(1500); } }
internal void EnterShareSkill(IWebDriver driver) { // Populate data saved in excel to collection GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ShareSkillPath, "ShareSkill"); // Click ShareSkill Button GlobalDefinitions.WaitForElementClickable(driver, "LinkText", "Share Skill", 5); ShareSkillBtn.Click(); // Wait Elements on new page GlobalDefinitions.WaitForTextPresentInElement(driver, Title, "", 10); // Enter Title from excel Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); // Enter Description from excel Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); // Select Category from Excel GlobalDefinitions.WaitForElement(driver, "Name", "categoryId", 10); new SelectElement(CategoryDropdown).SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); new SelectElement(SubCategoryDropdown).SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); // Enter tags from excel Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); // Choose Service Type radio button from excel IWebElement ServiceTypeRadioBtn = driver.FindElement(By.XPath("//input[@name='serviceType' " + "and @value='" + GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") + "'] ")); ServiceTypeRadioBtn.Click(); // Choose Location Type radio button from excel IWebElement LocationTypeRadioBtn = driver.FindElement(By.XPath("//input[@name='locationType' " + "and @value='" + GlobalDefinitions.ExcelLib.ReadData(2, "LocationType") + "']")); LocationTypeRadioBtn.Click(); // Enter Available days from excel // *** Enter start date and end date *** StartDateInputArea.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); EndDateInputArea.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); // *** Set loop for days checkbox *** for (int rows = 2; rows < 9; rows++) { var sr = GlobalDefinitions.ExcelLib.ReadData(rows, "SelectDay").ToString(); if (sr != null && sr != "") { // Select checkbox IWebElement DaysCheckbox = driver.FindElement(By.XPath("//input[@name='Available' " + "and @index='" + GlobalDefinitions.ExcelLib.ReadData(rows, "SelectDay") + "']")); DaysCheckbox.Click(); // Enter start time IWebElement StartTimeInputArea = driver.FindElement(By.XPath("//input[@name='StartTime' " + "and @index='" + GlobalDefinitions.ExcelLib.ReadData(rows, "SelectDay") + "']")); StartTimeInputArea.SendKeys(GlobalDefinitions.ExcelLib.ReadData(rows, "StartTime")); // Enter end time IWebElement EndTimeInputArea = driver.FindElement(By.XPath("//input[@name='EndTime' " + "and @index='" + GlobalDefinitions.ExcelLib.ReadData(rows, "SelectDay") + "']")); EndTimeInputArea.SendKeys(GlobalDefinitions.ExcelLib.ReadData(rows, "EndTime")); } else { break; } } // Choose Skill Trade radio button try { string SkillTradeTypeExcel = GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade").ToString(); IWebElement SkillTradeRadioBtn = driver.FindElement(By.XPath("//input[@name='skillTrades' " + "and @value='" + SkillTradeTypeExcel + "']")); SkillTradeRadioBtn.Click(); // Condition1: Enter Skill-Exchange from excel-------Condition2: Enter Credit if (SkillTradeTypeExcel == "true") { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange Tag")); SkillExchange.SendKeys(Keys.Enter); } if (SkillTradeTypeExcel == "false") { try { var CreditExcel = Convert.ToDecimal(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); if (0 <= CreditExcel && CreditExcel <= 10) { CreditAmount.SendKeys(CreditExcel.ToString()); } else { Assert.Fail("Please enter a number between 0-10."); } } catch (Exception e) { Assert.Fail("Credit input is illegal, please check format!", e.Message); } } } catch (Exception ex) { Assert.Fail("Test failed at choosing skill trade type", ex.Message); } //Upload document from the path saved in excel, if it's input type, then can send path directly // Option 1: SendKeys //try //{ // IWebElement upload = driver.FindElement(By.XPath("//input[@id='selectFile']")); // // Uploading File path // var SampleWorkPath = MarsResource.SampleWorkPath; // string fullPath = System.IO.Path.GetFullPath(SampleWorkPath); // upload.SendKeys(fullPath); //} //catch (Exception e) //{ // Assert.Fail("Failed to upload work sample", e.Message); //} // Option 2: AutoIt //driver.FindElement(By.ClassName("huge plus circle icon padding-25")).Click(); //Class Name Shouldn't have space inside, or use xpath or css. driver.FindElement(By.CssSelector("i[class='huge plus circle icon padding-25']")).Click(); AutoItX3 AutoIt = new AutoItX3(); AutoIt.WinActivate("Open"); // Must wait input text ready to input or will lose part of the url AutoIt.WinWaitActive("Open", "Edit", 3); var SampleWorkPath = MarsResource.SampleWorkPath; AutoIt.Send(Path.GetFullPath(SampleWorkPath)); Thread.Sleep(1500); AutoIt.Send("{ENTER}"); // Choose Active radio button GlobalDefinitions.WaitForElement(driver, "XPath", "//i[@class='remove sign icon floatRight']", 10); IWebElement IsActiveRadioBtn = driver.FindElement(By.XPath("//input[@name='isActive' and" + " @value='" + GlobalDefinitions.ExcelLib.ReadData(2, "Active") + "']")); IsActiveRadioBtn.Click(); // Click Save Button to save all data Save.Click(); }
internal void EditShareSkill() { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPathShareSkill, "EditShareSkill"); //Clear the existing Title and Enter new Title Title.Clear(); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title") + TimeStamp); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + Keys.Enter); //Disselect already entered day and time for (int i = 0; i < Days.Count; i++) { if (Days[i].Selected) { Days[i].Click(); StartTimeDropDown[i + 1].Clear(); EndTimeDropDown[i].Clear(); } } //Select Days and enter Start and End time if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sun") { //Select Sunday Days[0].Click(); //Enter StartTime from DropDown StartTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[0].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Mon") { //Select Monday Days[1].Click(); //Enter StartTime from DropDown StartTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Tue") { //Select Tuesday Days[2].Click(); //Enter StartTime from DropDown StartTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Wed") { //Select Wednesday Days[3].Click(); //Enter StartTime from DropDown StartTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Thu") { //Select Thursday Days[4].Click(); //Enter StartTime from DropDown StartTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Fri") { //Select Friday Days[5].Click(); //Enter StartTime from DropDown StartTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sat") { //Select Saturday Days[6].Click(); //Enter StartTime from DropDown StartTimeDropDown[7].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } //Select Skill Trade from options if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Skill-Exchange") { //Select Skill-exchange from available options SkillTradeOption[0].Click(); //Enter SkillExchange SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + Keys.Enter); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Credit") { //Select Credit from available options SkillTradeOption[1].Click(); //Enter Credit Amount CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Select ActiveOption switch ((GlobalDefinitions.ExcelLib.ReadData(2, "Active"))) { case "Active": //Select Active status ActiveOption[0].Click(); break; case "Hidden": //Select Hidden status ActiveOption[1].Click(); break; } //Click on Save button Save.Click(); //Waiting for Manage Listing page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//table[1]/tbody[1]"), 10); }
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")); }
//public void AddNewShareSkill() internal void AddNewSkill() { { #region Enter the deatils //Click on Share Skill button Thread.Sleep(1000); ShareSkills.Click(); Thread.Sleep(1000); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills"); // Enter Title Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Base.test.Log(LogStatus.Info, "Title has been successfully entered"); //Enter description Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Info, "Description has been successfully entered"); //click on category dropdown menu Thread.Sleep(500); Category.Click(); Thread.Sleep(1000); //Select the category Thread.Sleep(500); ProgrammingandTech.Click(); Thread.Sleep(500); //Click on subcatogory drop down option Thread.Sleep(1000); SubCategory.Click(); //Select the Sub-Category option Thread.Sleep(500); QA.Click(); Thread.Sleep(500); //Enter Tags Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "TagName has been successfully entered"); //Select service type //ServiceTypeHourly.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service") { ServiceTypeOneOff.Click(); } //Select Location Type //LocationTypeOnline.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online") { LocationTypeOnline.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site") { LocationTypeOnsite.Click(); } //Select the date Thread.Sleep(1000); StartDate.SendKeys(Keys.Delete); Thread.Sleep(2000); StartDate.SendKeys(Keys.Backspace); Thread.Sleep(1000); StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); Console.WriteLine("Start date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //StartDate.SendKeys("25-07-2019"); ////Select the end Date //EndDate.SendKeys("21-08-2019"); Thread.Sleep(1000); EndDate.SendKeys(Keys.Delete); EndDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); Thread.Sleep(2000); Console.WriteLine("End date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); //Select the Days available SelectDays.Click(); Thread.Sleep(500); //Select starttime Thread.Sleep(1000); StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); Thread.Sleep(2000); Console.WriteLine("Start Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); //StartTime.SendKeys("12:00PM"); //Select EndTime Thread.Sleep(1000); EndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); Console.WriteLine("End Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); //EndTime.SendKeys("3:00PM"); //Select Skill Trade Credit.Click(); Thread.Sleep(500); if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange") { Skillstrade.Click(); Skillstrade.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")); Skillstrade.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); CreditAmount.SendKeys(Keys.Enter); //Enter credit amount // CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); //Select the stats // StatusActive.Click(); //Thread.Sleep(500); //select Work Sample Sample.Click(); AutoItX3 fileupload = new AutoItX3(); fileupload.WinActivate("Open"); Thread.Sleep(3000); fileupload.Send(@"C:\Users\harpr\OneDrive\Documents\Testing.jpg"); Thread.Sleep(1000); fileupload.Send("{ENTER}"); //Thread.Sleep(4000); Console.WriteLine("File has been uploaded successfully"); if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Active") { Active.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Hidden") { Hidden.Click(); } //Save the Share Skill Thread.Sleep(500); Save.Click(); Thread.Sleep(500); //Verify if newShared skill is saved Thread.Sleep(3000); string ShareSkillSucess = Global.GlobalDefinitions.driver.FindElement(By.XPath("//th[contains(text(),'Image')]")).Text; if (ShareSkillSucess == "Image") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Saved Skill Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Saving Skill Unsuccessful"); } } } #endregion }