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

Fixes selenium tests #1677

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
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
34 changes: 17 additions & 17 deletions nbgrader/tests/nbextensions/formgrade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ def _check_url(browser, port, url):

def _check_breadcrumbs(browser, *breadcrumbs):
# check that breadcrumbs are correct
elements = browser.find_elements_by_css_selector(".breadcrumb li")
elements = browser.find_elements(By.CSS_SELECTOR, ".breadcrumb li")
assert tuple([e.text for e in elements]) == breadcrumbs

# check that the active breadcrumb is correct
element = browser.find_element_by_css_selector(".breadcrumb li.active")
element = browser.find_element(By.CSS_SELECTOR, ".breadcrumb li.active")
assert element.text == breadcrumbs[-1]


def _click_link(browser, link_text, partial=False):
if partial:
WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, link_text)))
element = browser.find_element_by_partial_link_text(link_text)
element = browser.find_element(By.PARTIAL_LINK_TEXT, link_text)
else:
WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.LINK_TEXT, link_text)))
element = browser.find_element_by_link_text(link_text)
element = browser.find_element(By.LINK_TEXT, link_text)
element.click()


Expand Down Expand Up @@ -165,7 +165,7 @@ def _wait_for_formgrader(browser, port, url, retries=5):


def _click_element(browser, name):
browser.find_element_by_css_selector(name).click()
browser.find_element(By.CSS_SELECTOR, name).click()


def _focus_body(browser, num_tries=5):
Expand All @@ -185,57 +185,57 @@ def _focus_body(browser, num_tries=5):
def _send_keys_to_body(browser, *keys):
_wait_for_tag(browser, "body")
_focus_body(browser)
body = browser.find_element_by_tag_name("body")
body = browser.find_element(By.TAG_NAME, "body")
body.send_keys(*keys)


def _get_next_arrow(browser):
return browser.find_element_by_css_selector(".next a")
return browser.find_element(By.CSS_SELECTOR, ".next a")


def _get_comment_box(browser, index):
def comment_is_present(browser):
comments = browser.find_elements_by_css_selector(".comment")
comments = browser.find_elements(By.CSS_SELECTOR, ".comment")
if len(comments) <= index:
return False
return True

WebDriverWait(browser, 10).until(comment_is_present)
return browser.find_elements_by_css_selector(".comment")[index]
return browser.find_elements(By.CSS_SELECTOR, ".comment")[index]


def _get_score_box(browser, index):
def score_is_present(browser):
scores = browser.find_elements_by_css_selector(".score")
scores = browser.find_elements(By.CSS_SELECTOR, ".score")
if len(scores) <= index:
return False
return True

WebDriverWait(browser, 10).until(score_is_present)
return browser.find_elements_by_css_selector(".score")[index]
return browser.find_elements(By.CSS_SELECTOR, ".score")[index]


def _get_extra_credit_box(browser, index):
def extra_credit_is_present(browser):
extra_credits = browser.find_elements_by_css_selector(".extra-credit")
extra_credits = browser.find_elements(By.CSS_SELECTOR, ".extra-credit")
if len(extra_credits) <= index:
return False
return True

WebDriverWait(browser, 10).until(extra_credit_is_present)
return browser.find_elements_by_css_selector(".extra-credit")[index]
return browser.find_elements(By.CSS_SELECTOR, ".extra-credit")[index]


def _save_comment(browser, index):
_send_keys_to_body(browser, Keys.ESCAPE)
glyph = browser.find_elements_by_css_selector(".comment-saved")[index]
glyph = browser.find_elements(By.CSS_SELECTOR, ".comment-saved")[index]
WebDriverWait(browser, 10).until(lambda browser: glyph.is_displayed())
WebDriverWait(browser, 10).until(lambda browser: not glyph.is_displayed())


def _save_score(browser, index):
_send_keys_to_body(browser, Keys.ESCAPE)
glyph = browser.find_elements_by_css_selector(".score-saved")[index]
glyph = browser.find_elements(By.CSS_SELECTOR, ".score-saved")[index]
WebDriverWait(browser, 10).until(lambda browser: glyph.is_displayed())
WebDriverWait(browser, 10).until(lambda browser: not glyph.is_displayed())

Expand All @@ -247,7 +247,7 @@ def _get_needs_manual_grade(browser, name):

def _flag(browser):
_send_keys_to_body(browser, Keys.SHIFT, Keys.CONTROL, "f")
message = browser.find_element_by_id("statusmessage")
message = browser.find_element(By.ID, "statusmessage")
WebDriverWait(browser, 10).until(lambda browser: message.is_displayed())
WebDriverWait(browser, 10).until(lambda browser: not message.is_displayed())
return browser.execute_script("return $('#statusmessage').text();")
Expand Down Expand Up @@ -278,7 +278,7 @@ def _load_formgrade(browser, port, gradebook):

def _child_exists(elem, selector):
try:
elem.find_element_by_css_selector(selector)
elem.find_element(By.CSS_SELECTOR, selector)
except NoSuchElementException:
return False
else:
Expand Down
Loading