public void UpdateExistingLanguageWithDifferentLangLevel(IWebDriver driver) { //Populate Test Data ExcelLib.PopulateInCollection(ConstantUtils.TestDataPath, "Profile"); // Click Language tab WaitForElement(driver, "XPath", "//a[@data-tab='first']", 5); LanguageTab.Click(); // Click Edit WaitForElementClickable(driver, "XPath", "//*[@id='account-profile-section']//div[2]//div[2]//tbody[last()]/tr/td[3]/span[1]/i", 5); EditIcon.Click(); // Enter Language WaitForElement(driver, "XPath", "//input[@placeholder='Add Language']", 5); LanguageName.Clear(); LanguageName.SendKeys(ExcelLib.ReadData(5, "Language")); // Choose Language level 0-basic; 1-conversational; 2-fluent; 3-native LanguageDropdownBox.Click(); new SelectElement(LanguageDropdownBox).SelectByText (ExcelLib.ReadData(5, "Language Level")); // Click Update UpdateBtn.Click(); // Record the msg msg = "update an existing language with different language level"; }
public void UpdateExistingLanguage(IWebDriver driver) { // Add a new language AddLanguage(driver); Thread.Sleep(1000); // Click Language tab WaitForElement(driver, "XPath", "//a[@data-tab='first']", 5); LanguageTab.Click(); // Click Edit WaitForElementClickable(driver, "XPath", "//*[@id='account-profile-section']//div[2]//div[2]//tbody[last()]/tr/td[3]/span[1]/i", 5); EditIcon.Click(); // Enter Language WaitForElement(driver, "XPath", "//input[@placeholder='Add Language']", 5); LanguageName.Clear(); LanguageName.SendKeys(ExcelLib.ReadData(4, "Language")); // Choose Language level 0-basic; 1-conversational; 2-fluent; 3-native LanguageDropdownBox.Click(); new SelectElement(LanguageDropdownBox).SelectByText (ExcelLib.ReadData(4, "Language Level")); // Need using OpenQA.Selenium.Support.UI; // Click Update UpdateBtn.Click(); // Record the msg msg = "update an existing language"; }
public void EditData() { Thread.Sleep(7000); ManageListing.Click(); Thread.Sleep(7000); EditIcon.Click(); Thread.Sleep(7000); Service.Click(); Thread.Sleep(6000); Save.Click(); }
//[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 UpdateSkill(IWebDriver driver, string skillName, string skillLevel) { // Click Skill tab WaitForElement(driver, "XPath", "//a[@data-tab='second']", 5); SkillTab.Click(); // Click Edit WaitForElementClickable(driver, "XPath", "//*[@id='account-profile-section']//div[3]/form/div[3]//div[2]//tbody[2]/tr/td[3]/span[1]/i", 5); EditIcon.Click(); // Update Skill WaitForElement(driver, "XPath", "//input[@placeholder='Add Skill']", 5); SkillName.Clear(); SkillName.SendKeys(skillName); // Choose Skill level SkillDropdownBox.Click(); new SelectElement(SkillDropdownBox).SelectByText(skillLevel); // Click Update UpdateBtn.Click(); }
public void EditUser() { EditIcon.Click(); }
internal void EditListing() { //Clicking on the "Manage Listing" tab MgmtListTab.Click(); //Clicking on the "Edit Icon" Thread.Sleep(2000); EditIcon.Click(); Thread.Sleep(2000); //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "EditListing"); //Edit the Title Title.Clear(); Thread.Sleep(500); Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Base.test.Log(LogStatus.Pass, "Title has succesfully been edited"); //Edit the Description Description.Clear(); Thread.Sleep(500); Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Pass, "Description has succesfully been edited"); //Select a category from dropdown GlobalDefinitions.wait(2); Actions action = new Actions(GlobalDefinitions.driver); action.MoveToElement(category).Build().Perform(); Thread.Sleep(1000); IList <IWebElement> Categorylist = category.FindElements(By.TagName("option")); int count = Categorylist.Count; Thread.Sleep(1500); for (int i = 1; i < count; i++) { if (Categorylist[i].Text == ExcelLib.ReadData(2, "category").Trim()) { Thread.Sleep(500); Categorylist[i].Click(); Thread.Sleep(500); Base.test.Log(LogStatus.Info, "Category has succesfully been edited"); } } //Edit the Subcategory Thread.Sleep(2000); action.MoveToElement(Subcategory).Build().Perform(); Thread.Sleep(1000); IList <IWebElement> SubCat = Subcategory.FindElements(By.TagName("option")); int SubCatCount = SubCat.Count; for (int i = 0; i < SubCatCount; i++) { if (SubCat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Subcategory")) { SubCat[i].Click(); Base.test.Log(LogStatus.Pass, "Subcategory has succesfully been edited"); } } //Edit the Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Thread.Sleep(1000); Tags.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Pass, "Tag has succesfully been edited"); //Edit the Service Type----------------------- // Storing all the elements under category of 'Service Type' in the list of WebLements IList <IWebElement> AllRadioButtons = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='serviceType']")); //Indicating the number of buttons present int Size = AllRadioButtons.Count; //Starting the loop from the first radio button to the last radio button of Service Type for (int i = 0; i < Size; i++) { //Storing the radio button to the string variable "Value", using the "value" attribute string Value = AllRadioButtons.ElementAt(i).GetAttribute("value"); int j = i + 1; var Name = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[5]/div[2]/div[1]/div[" + j + "]/div/label")).Text; //Checking if Name equals the "name" attribute - "locationType" if (Name.Equals(ExcelLib.ReadData(2, "ServiceType")) && Value.Equals("" + i)) { AllRadioButtons.ElementAt(i).Click(); Base.test.Log(LogStatus.Pass, "Service Type has succesfully been edited"); } } //Editing the Location Type IList <IWebElement> AllTypes = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='locationType']")); int Types = AllTypes.Count; for (int i = 0; i < Types; i++) { string Type = AllTypes.ElementAt(i).GetAttribute("value"); int k = i + 1; var Name = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']//div[2]/div/form/div[6]/div[2]/div/div[" + k + "]/div/label")).Text; //Checking if Name equals the "name" attribute - "locationType" if (Name.Equals(ExcelLib.ReadData(2, "LocationType")) && Type.Equals("" + i)) { AllTypes.ElementAt(i).Click(); Base.test.Log(LogStatus.Pass, "Location Type has succesfully been edited"); } } // Editing Available Days -Start Date Thread.Sleep(1000); StartDate.SendKeys(Keys.Delete); Thread.Sleep(500); StartDate.SendKeys("25/04/2019"); Thread.Sleep(500); StartDate.SendKeys(Keys.Tab); Base.test.Log(LogStatus.Pass, "Start Date has succesfully been edited"); //Editing Available Days - End Date Thread.Sleep(1000); EndDate.SendKeys(Keys.Delete); Thread.Sleep(500); EndDate.SendKeys("24/12/2020"); //EndDate.SendKeys(ExcelLib.ReadData(2, "EndDate")); Thread.Sleep(500); EndDate.SendKeys(Keys.Tab); Base.test.Log(LogStatus.Pass, "End Date has succesfully been edited"); //Editing Day Day.Click(); //Editing Start Hour StartHours.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartHour")); //Editing End Hour GlobalDefinitions.wait(5); EndHours.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndHour")); //Editing Skill Trade radio button IList <IWebElement> OneSelection = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='skillTrades']")); bool aValue = false; aValue = OneSelection.ElementAtOrDefault(0).Selected; if (aValue == true) { OneSelection.ElementAt(1).Click(); Thread.Sleep(1500); Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); Base.test.Log(LogStatus.Pass, "Skill Trade has succesfully been edited"); } else { OneSelection.ElementAt(0).Click(); Thread.Sleep(1500); SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchange")); Base.test.Log(LogStatus.Pass, "Skill Trade has not been edited"); } //Editing "Active" button - whether enable or disable service IList <IWebElement> OneRadioButton = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='isActive']")); bool bValue = false; bValue = OneRadioButton.ElementAtOrDefault(0).Selected; if (bValue == true) { OneRadioButton.ElementAt(1).Click(); } else { OneRadioButton.ElementAt(0).Click(); } Thread.Sleep(3000); string ActualValue = GlobalDefinitions.ExcelLib.ReadData(2, "Active Service"); Thread.Sleep(3000); string ExpectedValue = "Hidden"; if (ExpectedValue.Trim().Equals(ActualValue.Trim())) //if (ExpectedValue == ActualValue) { Base.test.Log(LogStatus.Pass, "Service is disabled"); } else { Base.test.Log(LogStatus.Fail, "Service is enabled"); } //Clicking on Save Button SaveButton.Click(); Base.test.Log(LogStatus.Pass, "Listing has successfully been edited"); //Check if the edited skill is present in the Manage Listings try { GlobalDefinitions.wait(2); string ExpectedTitle = ExcelLib.ReadData(2, "Title"); string BeforeXPath = "//div[@id='listing-management-section']/div[2]/div/table/tbody/tr["; Thread.Sleep(2000); string AfterXpath = "]/td[3]"; for (int i = 1; i <= 5; i++) { GlobalDefinitions.wait(2); string ColElements = driver.FindElement(By.XPath(BeforeXPath + i + AfterXpath)).Text; if (ColElements.Contains(ExpectedTitle)) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Edited Listing is displayed on the Listing Service page "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Edited Listing is displayed on the Listing Service page"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); break; } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edited Listing is not displayed on the Listing Service page "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Edited Listing is not displayed on the Listing Service page"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } } } catch (Exception e) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Error while displaying the edited listing" + e.Message); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Error, the listing has not been edited"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } }