public void RemoveAllServices() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ListingManagement"); Global.GlobalDefinitions.wait(2000); ManageListing.Click(); Base.test.Log(LogStatus.Info, "Starting removing Service"); Global.GlobalDefinitions.wait(5000); try { foreach (IWebElement ele in Remove) { WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable((ele))); ele.Click(); ModalYesButton.Click(); Global.GlobalDefinitions.wait(5000); } } catch (Exception e) { IWebElement NoListings = Global.GlobalDefinitions.driver.FindElement(By.XPath("//h3[contains(text(),'You do not have any service listings!')]")); if (NoListing.Displayed) { Global.Base.test.Log(LogStatus.Info, "There are no services to remove"); } else { Global.Base.test.Log(LogStatus.Info, "Something went wrong!" + e); } } }
public void EditServiceDetails() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ListingManagement"); ManageListing.Click(); Base.test.Log(LogStatus.Info, "Starting editing Service"); Global.GlobalDefinitions.wait(5000); bool RecordFound = false; try { for (int p = 0; p < NoOfPages.Count; p++) { for (int i = 0; i < Title.Count; i++) { if ((Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title") == Title[i].Text) && (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category") == Category[i].Text)) { RecordFound = true; Edit[i].Click(); ServiceListing service = new ServiceListing(); service.AddService(); Global.GlobalDefinitions.wait(2000); i = i + 1; } } if (NextPage.Enabled) { NextPage.Click(); } else if (RecordFound == false) { Global.Base.test.Log(LogStatus.Info, "There are no matching listings!"); } } } catch (Exception e) { IWebElement NoListings = Global.GlobalDefinitions.driver.FindElement(By.XPath("//h3[contains(text(),'You do not have any service listings!')]")); if (NoListings.Displayed) { Global.Base.test.Log(LogStatus.Info, "You do not have any service listings to display"); } else { Global.Base.test.Log(LogStatus.Info, "Something went wrong!" + e); } } }
//[FindsBy(How = How.XPath, Using = "//label[contains(text(),'Hourly basis service')]")] //private IWebElement ActualResult1 { get; set; } public void EditData() { Thread.Sleep(7000); ManageListing.Click(); Thread.Sleep(7000); EditIcon.Click(); Thread.Sleep(7000); Service.Click(); Thread.Sleep(6000); Save.Click(); //verify Thread.Sleep(9000); ManagelistingsMenu.Click(); Thread.Sleep(9000); try { Console.WriteLine("Entered try"); EditIcon.Click(); //if selected true Assert.IsFalse(Service.Selected); { Console.WriteLine("Test case 2 PASS : Record not edited"); Base.test.Log(LogStatus.Info, "Editing Done"); } ////Screenshot //String img = Global.GlobalDefinitions.SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.Driver, "Report"); ////AddScreenCapture(@"E:\Dropbox\VisualStudio\Projects\Beehive\TestReports\ScreenShots\"); //Base.test.Log(LogStatus.Info, "Image example: " + img); //// end test. (Reports) //Base.extent.EndTest(Base.test); //// calling Flush writes everything to the log file (Reports) //Base.extent.Flush(); } catch (Exception e) { Console.WriteLine(e); } }
public void DeleteData() { Thread.Sleep(7000); ManageListing.Click(); Thread.Sleep(7000); DeleteIcon.Click(); ConfirmYes.Click(); Thread.Sleep(4000); //Verfication try { Assert.IsTrue(ActResult3.Displayed); Console.WriteLine("Test 3 Pass : Record deleted successfully"); Base.test.Log(LogStatus.Info, "Deleting Done"); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Saves the service record details given in the excel sheet data for given number of records <paramref name="RecordNo"/> and /// returns data if record successfully saved /// </summary> /// <returns> /// If the record exists in the table /// </returns> /// <param name="RecordNo">The number of records to be saved as int Value </param> internal string SaveNew(int RecordNo) { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ServiceListing"); Thread.Sleep(1000); //Record Row No Starts with 2 in the DataSet RecordNo += 2; //Enter Title string TitleInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Title"); Title.SendKeys(TitleInput); //Enter Description string DescriptionInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Description"); Description.SendKeys(DescriptionInput); //Select Category string CategoryInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Category"); if (!("" == CategoryInput || null == CategoryInput)) { ValidateCategory(CategoryInput); var selectCategory = new SelectElement(Category); selectCategory.SelectByText(CategoryInput); Thread.Sleep(1000); } //Select SubCategory string SubCategoryInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SubCategory"); if (!("" == SubCategoryInput || null == SubCategoryInput)) { ValidateSubCategory(SubCategoryInput); var selectSubCatElement = new SelectElement(SubCategory); selectSubCatElement.SelectByText(SubCategoryInput); Thread.Sleep(500); } //Add tags //Multiple Tag values are supported using ',' seperater under the Tags column var TagsInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Tags"); string[] Inputs = TagsInput.Split(','); foreach (var tag in Inputs) { Tags.SendKeys(tag); Tags.SendKeys(Keys.Enter); Thread.Sleep(200); } //Select Service Type var ServiceTypeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "ServiceType"); if (!("" == ServiceTypeInput || null == ServiceTypeInput)) { ValidateServiceType(ServiceTypeInput); if (ServiceTypeInput == "Hourly basis service") { ServiceTypeHourlyBased.Click(); } else { ServiceTypeOneOff.Click(); } Thread.Sleep(500); } //Select Location Type var LocationTypeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "LocationType"); if (!("" == LocationTypeInput || null == LocationTypeInput)) { ValidateLocationType(LocationTypeInput); if (LocationTypeInput == "On-site") { LocationTypeOnSite.Click(); } else { LocationTypeOnline.Click(); } Thread.Sleep(500); } //Enter available days var StartDateInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartDate"); var StartMonthInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartMonth"); var StartYearInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartYear"); var EndDateInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndDate"); var EndMonthInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndMonth"); var EndYearInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndYear"); var AvailDaysInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "AvailableDays"); var StartTimeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartTime"); var EndTimeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndTime"); if (StartDateInput != "") { StartDate.SendKeys(StartMonthInput); Thread.Sleep(200); StartDate.SendKeys(StartDateInput); Thread.Sleep(200); StartDate.SendKeys(StartYearInput); Thread.Sleep(500); } if (EndDateInput != "") { EndDate.SendKeys(EndMonthInput); Thread.Sleep(200); EndDate.SendKeys(EndDateInput); Thread.Sleep(200); EndDate.SendKeys(EndYearInput); Thread.Sleep(500); } string[] Days = AvailDaysInput.Split(','); foreach (var AvailDay in Days) { switch (AvailDay) { case "Sun": SunCheckBox.Click(); SunStartTime.SendKeys(StartTimeInput); SunEndTime.SendKeys(EndTimeInput); break; case "Mon": MonCheckBox.Click(); MonStartTime.SendKeys(StartTimeInput); MonEndTime.SendKeys(EndTimeInput); break; case "Tue": TueCheckBox.Click(); TueStartTime.SendKeys(StartTimeInput); TueEndTime.SendKeys(EndTimeInput); break; case "Wed": WedCheckBox.Click(); WedStartTime.SendKeys(StartTimeInput); WedEndTime.SendKeys(EndTimeInput); break; case "Thur": ThursCheckBox.Click(); ThursStartTime.SendKeys(StartTimeInput); ThursEndTime.SendKeys(EndTimeInput); break; case "Fri": FriCheckBox.Click(); FriStartTime.SendKeys(StartTimeInput); FriEndTime.SendKeys(EndTimeInput); break; case "Sat": SatCheckBox.Click(); SatStartTime.SendKeys(StartTimeInput); SatEndTime.SendKeys(EndTimeInput); break; } Thread.Sleep(300); } //Select Skill Trade var SkillTradeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillTrade"); if (!("" == SkillTradeInput || null == SkillTradeInput)) { ValidateSkillTradeOption(SkillTradeInput); if (SkillTradeInput == "Skill-exchange") { SkillTradeExchange.Click(); Thread.Sleep(500); //Add Skill Exchange Tags //Multiple Tag values are supported using ',' seperater under the Skill Exchange Tags column var SkillExTagsInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillExchangeTags"); if (SkillExTagsInput != "") { string[] SkillExTags = SkillExTagsInput.Split(','); foreach (var skill in SkillExTags) { SkillExchangeTags.SendKeys(skill); SkillExchangeTags.SendKeys(Keys.Enter); Thread.Sleep(300); } } } else { SkillTradeCredit.Click(); Thread.Sleep(500); //Add Skill Trade Credit Amount var SkillCreditAmountInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillTradeCredit"); Thread.Sleep(500); if (SkillCreditAmountInput != "") { ChargeAmount.SendKeys(SkillCreditAmountInput); Thread.Sleep(500); } } } //Add Work Samples var WorkSampleInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "WorkSamples"); if (WorkSampleInput != "") { WorkSampleUpload.Click(); AutoItX3 autoItX3 = new AutoItX3(); autoItX3.WinActivate("File Upload"); Thread.Sleep(200); autoItX3.Send(@WorkSampleInput); Thread.Sleep(500); autoItX3.Send("{ENTER}"); Thread.Sleep(1000); } //Select Active Status var ActiveInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Active"); if (!("" == ActiveInput || null == ActiveInput)) { ValidateActiveOption(ActiveInput); if (ActiveInput == "Active") { IsActive.Click(); } else { IsHidden.Click(); } Thread.Sleep(500); } //Save Service Details Save.Click(); Thread.Sleep(2000); //Check the saved record in the listings ManageListing manageListing = new ManageListing(); bool IsExist = manageListing.ValidateRecordInTable(CategoryInput, TitleInput); return(IsExist.ToString()); }
public void RemoveServiceDetails() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ListingManagement"); Global.GlobalDefinitions.wait(2000); ManageListing.Click(); Base.test.Log(LogStatus.Info, "Starting removing Service"); Global.GlobalDefinitions.wait(5000); bool RecordFound = false; int flag = 0; //try //{ // for (int p = 0; p < NoOfPages.Count; p++) // { // for (int i = 0; i < Title.Count; i++) // { // Console.WriteLine("i value:" + i); // if ((Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title") == Title[i].Text) && (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category") == Category[i].Text)) // { // RecordFound = true; // WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); // wait.Until(ExpectedConditions.ElementToBeClickable((Remove[i]))); // Remove[i].Click(); // Console.WriteLine("removing row:"+i); // Global.GlobalDefinitions.wait(2000); // ModalYesButton.Click(); // i = i - 1; // } // } // if (NextPage.Enabled) // NextPage.Click(); // else if (RecordFound == false) // { // Global.Base.test.Log(LogStatus.Info, "There are no matching listings!"); // } // } //} try { for (int p = 0; p < NoOfPages.Count; p++) { for (int i = 0; i < Title.Count; i++) { Global.GlobalDefinitions.wait(7000); if (flag == Title.Count) { break; } else if ((Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title") == Title[i].Text) && (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category") == Category[i].Text)) { RecordFound = true; WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable((Remove[i]))); Remove[i].Click(); ModalYesButton.Click(); Global.GlobalDefinitions.wait(2000); i = i - 1; flag++; } } if (NextPage.Enabled) { NextPage.Click(); } else if (RecordFound == false) { Global.Base.test.Log(LogStatus.Info, "There are no matching listings!"); } } } catch (Exception e) { IWebElement NoListings = Global.GlobalDefinitions.driver.FindElement(By.XPath("//h3[contains(text(),'You do not have any service listings!')]")); if (NoListing.Displayed) { Global.Base.test.Log(LogStatus.Info, "There are no services to remove"); } else { Global.Base.test.Log(LogStatus.Info, "Something went wrong!" + e); } } }