From c8605f189b4e1389cc98f695430a19a686703c2c Mon Sep 17 00:00:00 2001 From: M Pacer Date: Thu, 22 Mar 2018 14:07:35 -0700 Subject: [PATCH] use only_dir_links inside test to avoid clicking '..' or non-dir links --- notebook/tests/selenium/test_dashboard_nav.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/notebook/tests/selenium/test_dashboard_nav.py b/notebook/tests/selenium/test_dashboard_nav.py index e3fd3d4ca..aae4d7c75 100644 --- a/notebook/tests/selenium/test_dashboard_nav.py +++ b/notebook/tests/selenium/test_dashboard_nav.py @@ -34,20 +34,19 @@ def test_items(authenticated_browser): # Going down the tree to collect links while True: wait_for_selector(authenticated_browser, '.item_link') - items = get_list_items(authenticated_browser) - visited_dict[authenticated_browser.current_url] = items - print(authenticated_browser.current_url, len(items)) - if len(items)>1: - item = items[1] - url = item['link'] + current_url = authenticated_browser.current_url + items = visited_dict[current_url] = only_dir_links(authenticated_browser) + try: + item = items[0] + text, url = (item['label'], item['link']) item["element"].click() assert authenticated_browser.current_url == url - else: + except IndexError: break # Going back up the tree while we still have unvisited links while visited_dict: wait_for_selector(authenticated_browser, '.item_link') - current_items = get_list_items(authenticated_browser) + current_items = only_dir_links(authenticated_browser) current_items_links = [item["link"] for item in current_items] stored_items = visited_dict.pop(authenticated_browser.current_url) stored_items_links = [item["link"] for item in stored_items]