Skip to content
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: fix RelativeBy#near to take 2 parameters #13082

Merged
merged 8 commits into from
Jul 12, 2024

Conversation

pinterior
Copy link
Contributor

@pinterior pinterior commented Nov 1, 2023

Description

RelativeBy#near should take 2 parameters to specify target element (or locator) and distance.

also:

  • add more strict type hints on relative_locator.py
  • remove default arguments raises Exception
  • add some tests

Motivation and Context

want to find far element

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • on my side, some tests already fails on trunk, but newly created tests passed.

@titusfortner titusfortner added the support Issue or PR related to support classes label Nov 1, 2023
@titusfortner
Copy link
Member

  1. We can't change a public method without warning. We typically mark methods or parameters as obsolete for 2 releases before removing something.
  2. We aren't accepting changes in the support classes right now. We're meeting next week to decide how to approach this section of the code going forward.

@pinterior pinterior force-pushed the fix-relative-locator-near branch from 19faad6 to 0e958aa Compare November 2, 2023 04:38
@pinterior
Copy link
Contributor Author

pinterior commented Nov 2, 2023

  1. We can't change a public method without warning.

resurrected default None argument.
old locate_with(...).near(elem) style call still works with default distance argument, but need to use different name for near(element_or_locator, distance) method?

  1. We aren't accepting changes in the support classes right now.

sure.
hope near locating will be able to use with custom distance in the future.

@codecov-commenter
Copy link

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (1d14b55) 57.65% compared to head (02b4a30) 58.03%.
Report is 115 commits behind head on trunk.

❗ Current head 02b4a30 differs from pull request most recent head 0e958aa. Consider uploading reports for the commit 0e958aa to get more accurate results

Files Patch % Lines
py/selenium/webdriver/support/relative_locator.py 89.36% 1 Missing and 4 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #13082      +/-   ##
==========================================
+ Coverage   57.65%   58.03%   +0.37%     
==========================================
  Files          86       86              
  Lines        5281     5319      +38     
  Branches      208      204       -4     
==========================================
+ Hits         3045     3087      +42     
  Misses       2028     2028              
+ Partials      208      204       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@diemol
Copy link
Member

diemol commented Nov 27, 2023

The "issue" is that Java and C# already accept distance as a parameter. JavaScript and Python don't, and I did not understand the Ruby code to know whether it accepts it.

@pinterior
Copy link
Contributor Author

the main issue is following near method looks like to take single int parameter, but it doesn't work.

    def near(self, element_or_locator_distance: Union[WebElement, Dict, int] = None) -> "RelativeBy":

@diemol
Copy link
Member

diemol commented Nov 27, 2023

the main issue is following near method looks like to take single int parameter, but it doesn't work.

    def near(self, element_or_locator_distance: Union[WebElement, Dict, int] = None) -> "RelativeBy":

Good point. Where can I see the failed test that shows the bug on the current implementation?

@pinterior pinterior force-pushed the fix-relative-locator-near branch from 0e958aa to 7f9cf88 Compare November 27, 2023 11:11
@pinterior
Copy link
Contributor Author

running test on faddc1b clearly shows near(123) fails with InvalidArgumentException

@diemol
Copy link
Member

diemol commented Jul 12, 2024

@pinterior can you please fix the linting so I can merge this?

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Thank you!

@diemol diemol merged commit 9aa1a7f into SeleniumHQ:trunk Jul 12, 2024
13 checks passed
sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Oct 29, 2024
* add failing test to check RelativeLocator#near accept single int

* fix s.w.support.RelativeBy#near to take 2 parameters

* more strict typing on s.w.support.relative_locator

* add some tests for s.w.support.relative_locator

* remove test case calling RelativeLocator#near wrong way

* fix linting issues

---------

Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs decision C-py support Issue or PR related to support classes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants