Commit 102c9775 by raeeschachar

LT-53 Do not leave the help window open after verification

parent f7aed5cb
...@@ -816,7 +816,7 @@ def create_user_partition_json(partition_id, name, description, groups, scheme=" ...@@ -816,7 +816,7 @@ def create_user_partition_json(partition_id, name, description, groups, scheme="
).to_json() ).to_json()
def assert_nav_help_link(test, page, href, signed_in=True): def assert_nav_help_link(test, page, href, signed_in=True, close_window=True):
""" """
Asserts that help link in navigation bar is correct. Asserts that help link in navigation bar is correct.
...@@ -827,7 +827,8 @@ def assert_nav_help_link(test, page, href, signed_in=True): ...@@ -827,7 +827,8 @@ def assert_nav_help_link(test, page, href, signed_in=True):
test (AcceptanceTest): Test object test (AcceptanceTest): Test object
page (PageObject): Page object to perform tests on. page (PageObject): Page object to perform tests on.
href (str): The help link which we expect to see when it is opened. href (str): The help link which we expect to see when it is opened.
signed_in (bool): Specifies whether user is logged in or not. (It effects the css) signed_in (bool): Specifies whether user is logged in or not. (It affects the css)
close_window(bool): Close the newly-opened help window before continuing
""" """
expected_link = { expected_link = {
'href': href, 'href': href,
...@@ -839,9 +840,12 @@ def assert_nav_help_link(test, page, href, signed_in=True): ...@@ -839,9 +840,12 @@ def assert_nav_help_link(test, page, href, signed_in=True):
assert_link(test, expected_link, actual_link) assert_link(test, expected_link, actual_link)
# Assert that opened link is correct # Assert that opened link is correct
assert_opened_help_link_is_correct(test, href) assert_opened_help_link_is_correct(test, href)
# Close the help window if not kept open intentionally
if close_window:
close_help_window(page)
def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, index=-1): def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, index=-1, close_window=True):
""" """
Asserts that help link in side bar is correct. Asserts that help link in side bar is correct.
...@@ -856,6 +860,7 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, i ...@@ -856,6 +860,7 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, i
'li' inside a sidebar list DOM element. 'li' inside a sidebar list DOM element.
index (int): The index of element in case there are more than index (int): The index of element in case there are more than
one matching elements. one matching elements.
close_window(bool): Close the newly-opened help window before continuing
""" """
expected_link = { expected_link = {
'href': href, 'href': href,
...@@ -867,6 +872,21 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, i ...@@ -867,6 +872,21 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False, i
assert_link(test, expected_link, actual_link) assert_link(test, expected_link, actual_link)
# Assert that opened link is correct # Assert that opened link is correct
assert_opened_help_link_is_correct(test, href) assert_opened_help_link_is_correct(test, href)
# Close the help window if not kept open intentionally
if close_window:
close_help_window(page)
def close_help_window(page):
"""
Closes the help window
Args:
page (PageObject): Page object to perform tests on.
"""
browser_url = page.browser.current_url
if browser_url.startswith('https://edx.readthedocs.io') or browser_url.startswith('http://edx.readthedocs.io'):
page.browser.close() # close only the current window
page.browser.switch_to_window(page.browser.window_handles[0])
class TestWithSearchIndexMixin(object): class TestWithSearchIndexMixin(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment