public HelloWebWithPageObjectTests() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); testComment = new ExampleComment(); testNote = new ExampleNote(); }
internal void AddNote(ExampleNote testNote) { { WaitForVisable(By.CssSelector("#menu-posts > a > div.wp-menu-name"), 10); _driver.FindElement(By.CssSelector("#menu-posts > a > div.wp-menu-name")).Click(); WaitForVisable(By.CssSelector("[class='page-title-action']"), 10); _driver.FindElement(By.CssSelector("[class='page-title-action']")).Click(); WaitForVisable(By.CssSelector("[id='title-prompt-text']"), 10); var enterTitle = _driver.FindElement(By.CssSelector("[id='title-prompt-text']")); enterTitle.Click(); _driver.FindElement(By.CssSelector("[id='title']")).SendKeys(testNote.egNote); var content = _driver.FindElement(By.CssSelector("[id='content']")); content.Click(); content.SendKeys(testNote.egText); WaitForVisable((By.CssSelector("[type='button'][aria-label='Edit permalink']")), 10); _driver.FindElement(By.CssSelector("[id='publish']")).Click(); _driver.FindElement(By.CssSelector("[class='avatar avatar-32']")).Click(); _driver.FindElement(By.CssSelector("[class='ab-sign-out']")).Click(); } }
internal void DoLogin(ExampleNote testNote) { WaitForVisable(By.CssSelector("[id='usernameOrEmail']"), 10); var loginField = _driver.FindElement(By.CssSelector("[id='usernameOrEmail']")); loginField.Click(); loginField.SendKeys(testNote.Login); _driver.FindElement(By.CssSelector("[type='submit']")).Click(); WaitForVisable(By.CssSelector("#password"), 10); var passwordField = _driver.FindElement(By.CssSelector("#password")); passwordField.Click(); passwordField.SendKeys(testNote.Password); _driver.FindElement(By.CssSelector("#primary > div > main > div > div.wp-login__container > div > form > div.card.login__form > div.login__form-action > button")).Click(); }
internal void CheckIfNoteExists(ExampleNote testNote) { System.Threading.Thread.Sleep(4000); _driver.Navigate().GoToUrl("https://autotestdotnet.wordpress.com/"); IReadOnlyCollection <IWebElement> entryTitle = _driver.FindElements(By.CssSelector("article[id]")); var CheckEntryTitle = entryTitle.Where(c => c.FindElement(By.TagName("a")).Text.Contains(testNote.egNote)); var numberOfElements = CheckEntryTitle.Count(); //if (numberOfElements == 0) Assert.Single(CheckEntryTitle); var ReplayNote = CheckEntryTitle.First().FindElements(By.CssSelector("[class='entry-content']")); var OneNote = ReplayNote.Where(r => r.FindElement(By.TagName("p")).Text.Contains(testNote.egText)); Assert.Single(OneNote); }