Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update selenium tests#3412

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
takluyver merged 8 commits intojupyter:masterfrommpacer:update_selenium_tests
Mar 23, 2018
Merged
Changes from1 commit
Commits
Show all changes
8 commits
Select commitHold shift + click to select a range
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
PrevPrevious commit
NextNext commit
move check & wait from only_dir_links to get_list_items; add docstrings
  • Loading branch information
@mpacer
mpacer committedMar 22, 2018
commit47d2be4a5e02d6c50ed582d4f5981ae6a99ce57d
35 changes: 26 additions & 9 deletionsnotebook/tests/selenium/test_dashboard_nav.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,29 @@
from selenium.webdriver.support import expected_conditions as EC
pjoin = os.path.join


class PageError(Exception):
"""Error for an action being incompatible with the current jupyter web page.

"""
def __init__(self, message):
self.message = message



def get_list_items(browser):
"""Gets list items from a directory listing page

Raises PageError if not in directory listing page (url has tree in it)
"""
try:
assert 'tree' in browser.current_url
except PageError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a convoluted way of writingif 'tree' not in browser.current_url: , even if it was catching the right error. Let's stick to the simple if statement rather than using assert to achieve the same thing.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fair enough — changed.

raise PageError("You are not in the notebook's file tree view."
"This function can only be used the file tree context.")
# we need to make sure that at least one item link loads
wait_for_selector(browser, '.item_link')

return [{
'link': a.get_attribute('href'),
'label': a.find_element_by_class_name('item_name').text,
Expand All@@ -14,11 +36,9 @@ def get_list_items(browser):


def only_dir_links(browser):
try:
assert 'tree' in browser.current_url
except AssertionError:
raise("You currently ")
wait_for_selector(browser, '.item_link')
"""Return only links that point at other directories in the tree

"""
items = get_list_items(browser)
return [i for i in items if 'tree' in i['link'] and i['label'] != '..']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This will go wrong for any file that hastree in the name. Maybe that's unlikely, but I think it's worth doing it a bit more thoroughly.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ok addressed by using an explicit check for whether urls point to something in the tree (withurl_in_tree)


Expand All@@ -29,7 +49,6 @@ def wait_for_selector(browser, selector, timeout=10):


def test_items(authenticated_browser):
tree_root_url = authenticated_browser.current_url
visited_dict = {}
# Going down the tree to collect links
while True:
Expand All@@ -38,14 +57,12 @@ def test_items(authenticated_browser):
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
assert authenticated_browser.current_url ==item['link']
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 = only_dir_links(authenticated_browser)
current_items_links = [item["link"] for item in current_items]
stored_items = visited_dict.pop(authenticated_browser.current_url)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp