Пример #1
0
        public void UpdateBook()
        {
            Librarian_Login.Login(driver, homeURL); //User logins to the system.

            IWebElement BookManagementButton =
                driver.FindElement(By.XPath("//a[contains(text(),'Book Management')]"));

            BookManagementButton.Click();

            IWebElement EditFirstBook =  //User clicks "Edit" link on the first book.
                                        driver.FindElement(By.XPath("//*/tbody/tr[2]/td[5]/a"));

            EditFirstBook.Click();


            IWebElement NameField =                                                                 //User edits the information of the selected book.
                                    driver.FindElement(By.XPath("//*[@id='MainContent_txtName']")); //input[contains(@value,'Name')]
            string NameInput = "Flori Edit Test";

            NameField.Clear();
            NameField.SendKeys(NameInput);

            IWebElement AuthorList =
                driver.FindElement(By.XPath("//*[@id='MainContent_ddlAuthor']"));
            SelectElement Author       = new SelectElement(AuthorList);
            string        AuthorPicked = "Arthur Conan Doyle";

            Author.SelectByText(AuthorPicked);

            IWebElement GenreList =
                driver.FindElement(By.XPath("//*[@id='MainContent_ddlGenre']"));
            SelectElement Genre       = new SelectElement(GenreList);
            string        GenrePicked = "Historical Fiction";

            Genre.SelectByText(GenrePicked);

            IWebElement EditBook =    //User clicks the "Update" button
                                   driver.FindElement(By.XPath("//*[@id='MainContent_btnSubmit']"));

            EditBook.Click();


            IWebElement EditedBook =    //User verifies the change on the grid.
                                     driver.FindElement(By.XPath($"//tr[td[contains(text(),'{NameInput}')] and td[contains(text(),'{AuthorPicked}')] and td[contains(text(),'{GenrePicked}')]]"));
            bool status = EditedBook.Displayed;

            new WebDriverWait(driver,
                              System.TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementToBeClickable(EditedBook));
        }
Пример #2
0
        public void CreateBook()
        {
            Librarian_Login.Login(driver, homeURL);     //User logins to the system.

            IWebElement BookManagementButton =
                driver.FindElement(By.XPath("//a[contains(text(),'Book Management')]"));

            BookManagementButton.Click();

            WebDriverWait wait = new WebDriverWait(driver,
                                                   System.TimeSpan.FromSeconds(15));
            IWebElement CreateNewBook = wait.Until(ExpectedConditions.ElementToBeClickable       //User clicks the "Create new book" link.
                                                       ((By.XPath("/ html / body / form / div[3] / div[2] / p / a"))));

            CreateNewBook.Click();

            IWebElement NameField =                                                                 //User gives the book name, author and genre for the new book.
                                    driver.FindElement(By.XPath("//*[@id='MainContent_txtName']")); //alternate xpath: //input[contains(@id,'Name')]
            string NameInput = "Flori Test";

            NameField.SendKeys(NameInput);

            IWebElement AuthorList =
                driver.FindElement(By.XPath("//*[@id='MainContent_ddlAuthor']")); //alternate xpath: //select[contains(@id,'Author')]
            SelectElement Author       = new SelectElement(AuthorList);
            string        AuthorPicked = "Arthur Conan Doyle";

            Author.SelectByText(AuthorPicked);

            IWebElement GenreList =
                driver.FindElement(By.XPath("//*[@id='MainContent_ddlGenre']")); //alternate xpath: //select[contains(@id,'Genre')]
            SelectElement Genre       = new SelectElement(GenreList);
            string        GenrePicked = "Historical Fiction";

            Genre.SelectByText(GenrePicked);

            IWebElement InsertBook =        //User clicks the "Insert" button.
                                     driver.FindElement(By.XPath("//*[@id='MainContent_btnSubmit']"));

            InsertBook.Click();

            IWebElement AddedBook =         //User verifies the new book has been added to the grid.
                                    driver.FindElement(By.XPath($"//tr[td[contains(text(),'{NameInput}')] and td[contains(text(),'{AuthorPicked}')] and td[contains(text(),'{GenrePicked}')]]"));
            bool status = AddedBook.Displayed;

            new WebDriverWait(driver,
                              System.TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementToBeClickable(AddedBook));
        }
Пример #3
0
        public void CreateAuthor()
        {
            Librarian_Login.Login(driver, homeURL); //User logins to the system.

            IWebElement AuthorManagementButton =    //User navigates to Author management and clicks.
                                                 driver.FindElement(By.XPath("//a[contains(text(),'Author Management')]"));

            AuthorManagementButton.Click();

            WebDriverWait wait = new WebDriverWait(driver,
                                                   System.TimeSpan.FromSeconds(15));
            IWebElement CreateNewAuthor =    //User create new author by clicking the link "Create new author"
                                          wait.Until(ExpectedConditions.ElementToBeClickable
                                                         ((By.XPath("//a[contains(text(),'(Create new author)')]"))));

            CreateNewAuthor.Click();

            IWebElement NameField =     //User adds a new author information with name and age, and inserts into the grid.
                                    driver.FindElement(By.XPath("//input[contains(@id,'Name')]"));

            NameField.SendKeys(NameInput);

            IWebElement AgeField =
                driver.FindElement(By.XPath("//input[contains(@id,'Age')]"));

            AgeField.SendKeys(AgeInput);

            IWebElement InsertAuthor =      //User click the "Insert" button
                                       driver.FindElement(By.XPath("//input[contains(@value,'Insert')]"));

            InsertAuthor.Click();

            IWebElement AddedAuthor =       //User verifies the author has been added.
                                      driver.FindElement(By.XPath($"//tr[td[contains(text(),'{NameInput}')] and td[contains(text(),'{AgeInput}')]]"));
            bool status = AddedAuthor.Displayed;

            new WebDriverWait(driver,
                              System.TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementToBeClickable(AddedAuthor));
        }
Пример #4
0
 public void Verify_Button()
 {
     Librarian_Login.Login(driver, homeURL); //User logins to the system.
 }