-
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?
Fix select_top_level_subject() method #273
Conversation
Update Reviewer's Actions - Path to run the test as below |
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.
Mostly small stuff, and some other things we'll want to go over at Forest Fire. It might all be good, but I'm not familiar enough with the problem to say. It's also been awhile since I worked on selenium code, so my memory may not be working well. We will see!
Cheers,
@felliott
@@ -1,9 +1,13 @@ | |||
import time |
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.
nit: remove if unused
from urllib.parse import urljoin | ||
|
||
import ipdb |
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.
nit: remove if unused
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could this be constructed from top_level_subjects
, which has the same selector, but is a GroupLocator
? I wonder if there's a .first
method or something like that.
@@ -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' | |||
wait = WebDriverWait(self.driver, 20) |
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.
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 comment
The 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.
@@ -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' | |||
wait = WebDriverWait(self.driver, 20) | |||
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 comment
The 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.
'input.ember-checkbox.ember-view' | ||
) | ||
checkbox.click() | ||
subject.click() |
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.
Q: does this work? I always remember checkboxes being difficult to trigger a click on. If this works, awesome!
def __call__(self, driver: WebDriver): | ||
try: | ||
element_texts = [element.text for element in driver.find_elements(*self.locator)] | ||
return any([self.text in element_text for element_text in element_texts]) |
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.
Purpose
The purpose of update is to fix failed test step of test_edit_preprint test
Summary of Changes
Updated select_top_level_subject() method
Reviewer's Actions
git fetch <remote> pull/273/head:pshtohryn/ENG-6071/fix/select_top_level_subject
Run this test using
MacOS - pytest tests/test_preprints.py::TestPreprintWorkflow::test_edit_preprint -sv
Windows - pytest .\tests\test_preprints.py::TestPreprintWorkflow::test_edit_preprint -sv
Testing Changes Moving Forward
N/A
Ticket
https://openscience.atlassian.net/browse/ENG-6071