diff --git a/src/e2e/java/teammates/e2e/cases/InstructorHomePageE2ETest.java b/src/e2e/java/teammates/e2e/cases/InstructorHomePageE2ETest.java index 3122023012c..683e5fd8dc7 100644 --- a/src/e2e/java/teammates/e2e/cases/InstructorHomePageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/InstructorHomePageE2ETest.java @@ -73,6 +73,7 @@ public void allTests() { ______TS("search for valid student"); InstructorSearchPage searchPage = homePage.searchKeyword(studentToEmail.getName()); + searchPage.waitForPageToLoad(); // Here, it is sufficient to ensure that the number of search results matches // A more thorough testing of this page will be done in its own E2E test @@ -82,6 +83,7 @@ public void allTests() { ______TS("search for invalid student"); searchPage = homePage.searchKeyword("INVALID"); + searchPage.waitForPageToLoad(true); searchPage.verifyStatusMessage("No results found."); searchPage.verifyNumCoursesInStudentResults(0); diff --git a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java index 8a5aeeede3b..46dc71f60af 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java @@ -75,7 +75,6 @@ public void clickSearchButton() { public void regenerateLinksForStudent(StudentAttributes student) { WebElement studentRow = getStudentRow(student); studentRow.findElement(By.xpath("//button[text()='Regenerate links']")).click(); - waitForPageToLoad(); waitForConfirmationModalAndClickOk(); waitForPageToLoad(true); @@ -153,11 +152,11 @@ public String getStudentJoinLink(WebElement studentRow) { public void resetStudentGoogleId(StudentAttributes student) { WebElement studentRow = getStudentRow(student); - studentRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)).click(); - waitForPageToLoad(); + WebElement link = studentRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); + link.click(); waitForConfirmationModalAndClickOk(); - waitForPageToLoad(); + waitForElementStaleness(link); } public WebElement getInstructorRow(InstructorAttributes instructor) { @@ -201,11 +200,11 @@ public String getInstructorJoinLink(WebElement instructorRow) { public void resetInstructorGoogleId(InstructorAttributes instructor) { WebElement instructorRow = getInstructorRow(instructor); - instructorRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)).click(); - waitForPageToLoad(); + WebElement link = instructorRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); + link.click(); waitForConfirmationModalAndClickOk(); - waitForPageToLoad(); + waitForElementStaleness(link); } public int getNumExpandedRows(WebElement row) { diff --git a/src/e2e/java/teammates/e2e/pageobjects/AppPage.java b/src/e2e/java/teammates/e2e/pageobjects/AppPage.java index c99ccbbf087..864a7dd69a6 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/AppPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/AppPage.java @@ -182,9 +182,13 @@ public void waitForElementToBeClickable(WebElement element) { } public void waitUntilAnimationFinish() { - WebDriverWait wait = new WebDriverWait(browser.driver, 2); + WebDriverWait wait = new WebDriverWait(browser.driver, 3); wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("ng-animating"))); - ThreadHelper.waitFor(500); + ThreadHelper.waitFor(1000); + } + + public void waitForLoadingElement() { + waitForElementStaleness(waitForElementPresence(By.className("loading-container"))); } /** diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java index e4621310ed5..f48b2b2d3dc 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java @@ -300,6 +300,7 @@ private void clickAddNewInstructorButton() { private void clickEditInstructorButton(int instrNum) { click(getEditInstructorButton(instrNum)); + waitUntilAnimationFinish(); } private void clickCancelInstructorButton(int instrNum) { diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java index 2eb795198c1..41fc96049e5 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java @@ -37,15 +37,6 @@ public class InstructorCoursesPage extends AppPage { @FindBy(id = "btn-save-course") private WebElement submitButton; - @FindBy(id = "sort-course-name") - private WebElement sortByCourseNameIcon; - - @FindBy (id = "sort-course-id") - private WebElement sortByCourseIdIcon; - - @FindBy (id = "sort-creation-date") - private WebElement sortByCreationDateIcon; - @FindBy(id = "active-courses-table") private WebElement activeCoursesTable; @@ -220,15 +211,15 @@ public void deleteAllCourses() { } public void sortByCourseName() { - click(sortByCourseNameIcon); + click(waitForElementPresence(By.id("sort-course-name"))); } public void sortByCourseId() { - click(sortByCourseIdIcon); + click(waitForElementPresence(By.id("sort-course-id"))); } public void sortByCreationDate() { - click(sortByCreationDateIcon); + click(waitForElementPresence(By.id("sort-creation-date"))); } private WebElement getActiveTableRow(String courseId) { diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java index f4f3b802c0f..81781bd584a 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java @@ -50,9 +50,6 @@ public class InstructorFeedbackEditPage extends AppPage { @FindBy(id = "btn-fs-save") private WebElement fsSaveButton; - @FindBy(id = "btn-fs-delete") - private WebElement fsDeleteButton; - @FindBy(id = "btn-fs-copy") private WebElement fsCopyButton; @@ -290,7 +287,7 @@ public void copySessionToOtherCourse(CourseAttributes otherCourse, String sessio } public void deleteSession() { - clickAndConfirm(fsDeleteButton); + clickAndConfirm(waitForElementPresence(By.id("btn-fs-delete"))); } public FeedbackSubmitPage previewAsStudent(StudentAttributes student) { @@ -1143,7 +1140,12 @@ private void clickAndWaitForNewQuestion(WebElement button) { private void addNewQuestion(int optionNumber) { click(addNewQuestionButton); WebElement newQuestionDropdown = waitForElementPresence(By.id("new-question-dropdown")); - click(newQuestionDropdown.findElements(By.tagName("button")).get(optionNumber - 1)); + WebElement optionButton = newQuestionDropdown.findElements(By.tagName("button")).get(optionNumber - 1); + if (optionNumber == 1) { + click(optionButton); + } else { + clickAndWaitForNewQuestion(optionButton); + } } private void clickSaveNewQuestionButton() { diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorHomePage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorHomePage.java index 46c4c02e4ac..43a9bff6cc6 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorHomePage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorHomePage.java @@ -39,7 +39,7 @@ protected boolean containsExpectedPageContents() { public InstructorSearchPage searchKeyword(String keyword) { fillTextBox(searchBar, keyword); click(searchButton); - waitForPageToLoad(true); + waitUntilAnimationFinish(); return changePageType(InstructorSearchPage.class); } diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorSearchPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorSearchPage.java index f6d71608b76..7953dbbacfd 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorSearchPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorSearchPage.java @@ -60,8 +60,7 @@ public void search(boolean searchForStudents, boolean searchForComments, String searchKeyword.clear(); searchKeyword.sendKeys(searchTerm); click(searchButton); - waitForPageToLoad(true); - waitUntilAnimationFinish(); + waitForLoadingElement(); } else { verifyUnclickable(searchButton); }