- Notifications
You must be signed in to change notification settings - Fork5.5k
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
Uh oh!
There was an error while loading.Please reload this page.
Changes from3 commits
0c28482965970a1f549fcf4c90ebc8605f147d2be4f17e775e688774File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,43 +3,42 @@ | ||
| fromselenium.webdriver.common.byimportBy | ||
| fromselenium.webdriver.support.uiimportWebDriverWait | ||
| fromselenium.webdriver.supportimportexpected_conditionsasEC | ||
| pjoin=os.path.join | ||
| defget_list_items(browser): | ||
| return [{ | ||
| 'link':a.get_attribute('href'), | ||
| 'label':a.find_element_by_class_name('item_name').text, | ||
| 'element':a, | ||
| }forainbrowser.find_elements_by_class_name('item_link')] | ||
| defwait_for_selector(browser,selector,timeout=10): | ||
| wait=WebDriverWait(browser,timeout) | ||
| returnwait.until(EC.visibility_of_element_located((By.CSS_SELECTOR,selector))) | ||
| deftest_items(authenticated_browser): | ||
| tree_root_url=authenticated_browser.current_url | ||
| visited_dict= {} | ||
| # Going down the tree to collect links | ||
| whileTrue: | ||
| 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)) | ||
| iflen(items)>1: | ||
| ||
| item=items[1] | ||
| url=item['link'] | ||
| item["element"].click() | ||
| assertauthenticated_browser.current_url==url | ||
| else: | ||
| break | ||
| # Going back up the tree while we still have unvisited links | ||
| whilevisited_dict: | ||
| wait_for_selector(authenticated_browser,'.item_link') | ||
| current_items=get_list_items(authenticated_browser) | ||
| current_items_links= [item["link"]foritemincurrent_items] | ||
| stored_items=visited_dict.pop(authenticated_browser.current_url) | ||
| stored_items_links= [item["link"]foriteminstored_items] | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Neat, I like the comparison of what's here now vs what was here before. | ||
| assertstored_items_links==current_items_links | ||
| authenticated_browser.back() | ||