-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[py] Replace deprecated get_attribute() in tests #14807
base: trunk
Are you sure you want to change the base?
Conversation
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
CI Failure Feedback 🧐(Checks updated until commit 956318e)
|
aca6f88
to
d8e6ac0
Compare
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
d8e6ac0
to
956318e
Compare
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.
I am not into python, so this is review of the things from the perspective of a java developer.
@@ -43,6 +43,7 @@ | |||
T = TypeVar("T") | |||
|
|||
WebDriverOrWebElement = Union[WebDriver, WebElement] | |||
attr_get_property = ["value", "checked", "index", "selected"] |
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.
The "id" should be a property too, otherwise you only read ids defined in html.
All the .get_dom_attribute("id")
calls below should be replaced by get_property("id")
element_attribute = ( | ||
driver.find_element(*locator).get_dom_attribute(attribute_) | ||
if attribute_ not in attr_get_property | ||
else driver.find_element(*locator).get_property(attribute_) | ||
) |
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.
You might need to translate the names on the caller site if one of PROPERTY_ALIASES (defined in the /attribute.js) is used.
https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/webdriver/atoms/attribute.js
@@ -24,53 +24,53 @@ | |||
def test_should_return_null_when_getting_the_value_of_an_attribute_that_is_not_listed(driver, pages): |
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.
I think the tests for get_attribute
should stay as long as the method is not removed (there is currently no plan as faur as i can tell). New tests / files for get_dom_attribute
and get_property
should be added,
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Mostly changes in
get_attribute("value")
->get_property("value")
get_attribute("checked")
->get_property("checked")
get_attribute("index")
->get_property("index")
get_attribute("selected")
->get_property("selected")
get_dom_attribute()
Motivation and Context
Types of changes
Checklist
PR Type
enhancement, tests
Description
get_attribute()
method withget_property()
andget_dom_attribute()
across various files to align with updated WebDriver API practices.Changes walkthrough 📝
2 files
expected_conditions.py
Update element attribute and value checks in expected conditions
py/selenium/webdriver/support/expected_conditions.py
get_attribute()
withget_property()
for element value checks.get_attribute()
withget_dom_attribute()
for elementattribute checks.
select.py
Update index attribute checks in select elements
py/selenium/webdriver/support/select.py
get_attribute()
withget_dom_attribute()
for index checks inselect elements.
13 files
api_example_tests.py
Update attribute access methods in API example tests
py/test/selenium/webdriver/common/api_example_tests.py
get_attribute()
withget_property()
andget_dom_attribute()
in various tests.
children_finding_tests.py
Update child element attribute access in tests
py/test/selenium/webdriver/common/children_finding_tests.py
get_attribute()
withget_dom_attribute()
in child elementfinding tests.
clear_tests.py
Update input value checks in clear tests
py/test/selenium/webdriver/common/clear_tests.py
get_attribute()
withget_property()
for value checks afterclearing inputs.
correct_event_firing_tests.py
Update event firing checks for input values
py/test/selenium/webdriver/common/correct_event_firing_tests.py
get_attribute()
withget_property()
for event firing checks.driver_element_finding_tests.py
Update element attribute access in driver element finding tests
py/test/selenium/webdriver/common/driver_element_finding_tests.py
get_attribute()
withget_dom_attribute()
andget_property()
in element finding tests.
executing_async_javascript_tests.py
Update async JavaScript execution tests for attribute access
py/test/selenium/webdriver/common/executing_async_javascript_tests.py
get_attribute()
withget_property()
in async JavaScriptexecution tests.
form_handling_tests.py
Update form handling tests for attribute access
py/test/selenium/webdriver/common/form_handling_tests.py
get_attribute()
withget_property()
in form handling tests.frame_switching_tests.py
Update frame switching tests for attribute access
py/test/selenium/webdriver/common/frame_switching_tests.py
get_attribute()
withget_property()
andget_dom_attribute()
in frame switching tests.
interactions_tests.py
Update interaction tests for attribute access
py/test/selenium/webdriver/common/interactions_tests.py
get_attribute()
withget_property()
in interaction tests.interactions_with_device_tests.py
Update device interaction tests for attribute access
py/test/selenium/webdriver/common/interactions_with_device_tests.py
get_attribute()
withget_property()
in device interactiontests.
select_element_handling_tests.py
Update select element handling tests for attribute access
py/test/selenium/webdriver/common/select_element_handling_tests.py
get_attribute()
withget_property()
in select elementhandling tests.
stale_reference_tests.py
Update stale reference tests for attribute access
py/test/selenium/webdriver/common/stale_reference_tests.py
get_attribute()
withget_dom_attribute()
in stale referencetests.
text_handling_tests.py
Update text handling tests for attribute access
py/test/selenium/webdriver/common/text_handling_tests.py
get_attribute()
withget_property()
in text handling tests.