Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more inaccurate nbextension test failures after reruns #789

Merged
merged 2 commits into from
Jul 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions nbgrader/tests/nbextensions/test_formgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,14 +806,21 @@ def test_formgrade_show_hide_names(browser, port, gradebook):
assert hidden.is_displayed()


@pytest.mark.nbextensions
def test_before_add_new_assignment(browser, port, gradebook):
utils._load_gradebook_page(browser, port, "")
assert len(browser.find_elements_by_css_selector("tbody tr")) == 1


@pytest.mark.nbextensions
def test_add_new_assignment(browser, port, gradebook):
utils._load_gradebook_page(browser, port, "")
n = len(browser.find_elements_by_css_selector("tbody tr"))

# click the "add new assignment" button
utils._click_link(browser, "Add new assignment...")
utils._wait_for_element(browser, "add-assignment-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#add-assignment-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#add-assignment-modal .save")))

# set the name and dudedate
elem = browser.find_element_by_css_selector("#add-assignment-modal .name")
Expand All @@ -832,7 +839,7 @@ def test_add_new_assignment(browser, port, gradebook):
WebDriverWait(browser, 10).until(modal_not_present)

# wait until both rows are present
rows_present = lambda browser: len(browser.find_elements_by_css_selector("tbody tr")) == 2
rows_present = lambda browser: len(browser.find_elements_by_css_selector("tbody tr")) == (n + 1)
WebDriverWait(browser, 10).until(rows_present)

# check that the new row is correct
Expand Down Expand Up @@ -869,7 +876,7 @@ def test_edit_assignment(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".edit a").click()
utils._wait_for_element(browser, "edit-assignment-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#edit-assignment-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#edit-assignment-modal .save")))

# modify the duedate
elem = browser.find_element_by_css_selector("#edit-assignment-modal .modal-duedate")
Expand Down Expand Up @@ -917,7 +924,7 @@ def test_generate_assignment_fail(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".assign a").click()
utils._wait_for_element(browser, "error-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#error-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#error-modal .close")))
utils._click_element(browser, "#error-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#error-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand All @@ -935,7 +942,7 @@ def test_generate_assignment_success(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".assign a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand Down Expand Up @@ -981,7 +988,7 @@ def test_release_assignment(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".release a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand Down Expand Up @@ -1025,7 +1032,7 @@ def test_collect_assignment(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".collect a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand Down Expand Up @@ -1065,7 +1072,7 @@ def test_unrelease_assignment(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[1]
row.find_element_by_css_selector(".release a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand Down Expand Up @@ -1148,7 +1155,7 @@ def test_autograde_assignment1(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[0]
row.find_element_by_css_selector(".autograde a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand Down Expand Up @@ -1185,7 +1192,7 @@ def test_autograde_assignment2(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[0]
row.find_element_by_css_selector(".autograde a").click()
utils._wait_for_element(browser, "success-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#success-modal .close")))
utils._click_element(browser, "#success-modal .close")
modal_not_present = lambda browser: browser.execute_script("""return $("#success-modal").length === 0;""")
WebDriverWait(browser, 10).until(modal_not_present)
Expand All @@ -1211,14 +1218,20 @@ def test_autograde_assignment2(browser, port, gradebook):


@pytest.mark.nbextensions
def test_add_new_student(browser, port, gradebook):
def test_before_add_new_student(browser, port, gradebook):
utils._load_gradebook_page(browser, port, "manage_students")
assert len(browser.find_elements_by_css_selector("tbody tr")) == 3


@pytest.mark.nbextensions
def test_add_new_student(browser, port, gradebook):
utils._load_gradebook_page(browser, port, "manage_students")
n = len(browser.find_elements_by_css_selector("tbody tr"))

# click the "add new assignment" button
utils._click_link(browser, "Add new student...")
utils._wait_for_element(browser, "add-student-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#add-student-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#add-student-modal .save")))

# set the name and dudedate
elem = browser.find_element_by_css_selector("#add-student-modal .id")
Expand All @@ -1240,7 +1253,7 @@ def test_add_new_student(browser, port, gradebook):
WebDriverWait(browser, 10).until(modal_not_present)

# wait until both rows are present
rows_present = lambda browser: len(browser.find_elements_by_css_selector("tbody tr")) == 4
rows_present = lambda browser: len(browser.find_elements_by_css_selector("tbody tr")) == (n + 1)
WebDriverWait(browser, 10).until(rows_present)

# check that the new row is correct
Expand Down Expand Up @@ -1269,7 +1282,7 @@ def test_edit_student(browser, port, gradebook):
row = browser.find_elements_by_css_selector("tbody tr")[0]
row.find_element_by_css_selector(".edit a").click()
utils._wait_for_element(browser, "edit-student-modal")
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#edit-student-modal button.btn-primary")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#edit-student-modal .modal-email")))

# modify the duedate
elem = browser.find_element_by_css_selector("#edit-student-modal .modal-email")
Expand Down