public void CreatePerson() { PlaygroundPage(); Console.WriteLine("Playground page..."); PlaygroundPOM playground = new PlaygroundPOM(driver); playground.GotoPeoplePage(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.ClassName("btn-text"))); Assert.IsNotNull(element, "Expected to find Create person link, but there is none."); Console.WriteLine("People page..."); } catch (Exception) { throw; } PeoplePOM person = new PeoplePOM(driver); person.CreatePerson(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.Name("people_name"))); Assert.IsNotNull(element, "Expected to find full name input, but there is none"); Console.WriteLine("Create person..."); } catch (Exception) { throw; } EditPersonPOM editPerson = new EditPersonPOM(driver); string name = "Marko Marković"; editPerson.AddNewPerson(name, "", "", ""); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.LinkText(name))); Assert.IsNotNull(element, "Expected to find " + name + ", but there is none."); Console.WriteLine("Created person " + name); } catch (Exception) { throw; } }
public void EditPerson() { PlaygroundPage(); Console.WriteLine("Playground page..."); PlaygroundPOM playground = new PlaygroundPOM(driver); playground.GotoPeoplePage(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.ClassName("btn-text"))); Assert.IsNotNull(element, "Expected to find Create person link, but there is none."); Console.WriteLine("People page..."); } catch (Exception) { throw; } driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); string name = "Marko Marković"; bool personExists = false; var people = driver.FindElements(By.CssSelector("a.list-group-item.list-group-item-action")); foreach (var person in people) { if (person.GetAttribute("innerHTML") == name) { personExists = true; } } if (personExists) { driver.FindElement((By.LinkText(name))).Click(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.Name("people_name"))); Assert.IsNotNull(element, "Expected to find full name input, but there is none"); Console.WriteLine("Edit person " + name); } catch (Exception) { throw; } List <string> technologies = new List <string>(); technologies.Add("Java"); technologies.Add("PHP"); string seniority = "medior"; string team = "development team"; EditPersonPOM editPerson = new EditPersonPOM(driver); editPerson.EditPerson(null, technologies, seniority, team); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.ClassName("btn-text"))); Assert.IsNotNull(element, "Expected to find Create person link, but there is none."); Console.WriteLine("Person " + name + " has been modified."); } catch (Exception) { throw; } } else { Console.WriteLine("Person " + name + " does not exist."); } }
public void DeletePerson() { PlaygroundPage(); Console.WriteLine("Playground page..."); PlaygroundPOM playground = new PlaygroundPOM(driver); playground.GotoPeoplePage(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.ClassName("btn-text"))); Assert.IsNotNull(element, "Expected to find Create person link, but there is none."); Console.WriteLine("People page..."); } catch (Exception) { throw; } driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); string name = "Marko Marković"; bool personExists = false; var people = driver.FindElements(By.CssSelector("a.list-group-item.list-group-item-action")); foreach (var person in people) { if (person.GetAttribute("innerHTML") == name) { personExists = true; } } if (personExists) { driver.FindElement((By.LinkText(name))).Click(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.Name("people_name"))); Assert.IsNotNull(element, "Expected to find full name input, but there is none"); Console.WriteLine("Edit person " + name); } catch (Exception) { throw; } EditPersonPOM editPerson = new EditPersonPOM(driver); editPerson.DeletePerson(); try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement element = wait.Until <IWebElement>(d => d.FindElement(By.ClassName("btn-text"))); bool stillExists = false; people = driver.FindElements(By.CssSelector("a.list-group-item.list-group-item-action")); foreach (var person in people) { if (person.GetAttribute("innerHTML") == name) { stillExists = true; } } Assert.IsFalse(stillExists, "Person " + name + " is not deleted."); Console.WriteLine("Deleted person " + name); } catch (Exception) { throw; } } else { Console.WriteLine("Person " + name + " does not exist."); } }