Skip to content

Commit

Permalink
Fix timing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jtankw3 committed Nov 8, 2020
1 parent 5032519 commit a94b606
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
13 changes: 6 additions & 7 deletions src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/e2e/java/teammates/e2e/pageobjects/AppPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ private void clickAddNewInstructorButton() {

private void clickEditInstructorButton(int instrNum) {
click(getEditInstructorButton(instrNum));
waitUntilAnimationFinish();
}

private void clickCancelInstructorButton(int instrNum) {
Expand Down
15 changes: 3 additions & 12 deletions src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected boolean containsExpectedPageContents() {
public InstructorSearchPage searchKeyword(String keyword) {
fillTextBox(searchBar, keyword);
click(searchButton);
waitForPageToLoad(true);
waitUntilAnimationFinish();
return changePageType(InstructorSearchPage.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a94b606

Please sign in to comment.