-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix select_top_level_subject() method #273
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import time | ||
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. nit: remove if unused |
||
from urllib.parse import urljoin | ||
|
||
import ipdb | ||
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. nit: remove if unused |
||
import pytest | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
|
||
import settings | ||
from base.expected_conditions import text_to_be_present_in_elements | ||
from base.locators import ( | ||
ComponentLocator, | ||
GroupLocator, | ||
|
@@ -113,13 +117,12 @@ def select_from_dropdown_listbox(self, selection): | |
) | ||
|
||
def select_top_level_subject(self, selection): | ||
subject_selector = 'div[data-analytics-scope="Browse"] > ul > li' | ||
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. nit: could this be constructed from |
||
wait = WebDriverWait(self.driver, 20) | ||
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. question: 20 seconds sounds like a long time. Do we need that long? 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. Wait, this will bail early if the condition is met, correct? If so, 20s isn't the worst thing, but if it's taking that long, we might want a flag raised. This is probably an FF topic. |
||
wait.until(text_to_be_present_in_elements((By.CSS_SELECTOR, subject_selector), selection)) | ||
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. This might be fine, but isn't there a selector to check text contents? I'm pretty sure there's one for xpath, not sure about css. |
||
for subject in self.top_level_subjects: | ||
if subject.text == selection: | ||
# Find the checkbox element and click it to select the subject | ||
checkbox = subject.find_element_by_css_selector( | ||
'input.ember-checkbox.ember-view' | ||
) | ||
checkbox.click() | ||
subject.click() | ||
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. Q: does this work? I always remember checkboxes being difficult to trigger a click on. If this works, awesome! |
||
break | ||
|
||
first_selected_subject = Locator(By.CSS_SELECTOR, 'li[data-test-selected-subject]') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't use a "contains-text" selector, could these lines be combined to help the check short-circuit faster?. I'm not sure, but it might be worth investigating.