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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

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
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
Copy link
Contributor Author

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

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.

None yet

5 participants