[py] Extract alert and color into dedicated libraries #17611
Open
AutomatedTester wants to merge 2 commits into
Open
[py] Extract alert and color into dedicated libraries #17611AutomatedTester wants to merge 2 commits into
AutomatedTester wants to merge 2 commits into
Conversation
- Extract selenium/webdriver/common/alert.py into //py:common_alert; lazy-import Alert in switch_to.py (body) and expected_conditions.py (TYPE_CHECKING) so //py:remote and //py:support no longer carry the compile-time dep. - Extract selenium/webdriver/support/color.py into //py:support_color; no source changes needed since no other library imports it. - Group alerts_tests.py + webdriverwait_tests.py into ALERT_TESTS (both call driver.switch_to.alert at runtime, requiring :common_alert). - Add RENDERED_WEBELEMENT_TESTS for rendered_webelement_tests.py (sole browser test importing Color). - Both groups added to FEATURE_TESTS (excluded from *-common suites) and FEATURE_SUITE_DEFS, generating test-<browser>-alerts and test-<browser>-rendered sub-suites across all browser/bidi/remote variants. - Add :common_alert and :support_color to //py:selenium deps.
Member
|
Thank you, @AutomatedTester for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
Member
Author
bidi_browsing_context_tests.py calls EC.alert_is_present() which triggers driver.switch_to.alert at runtime, requiring alert.py in the runfiles. The bidi-common suite includes BIDI_TESTS (unlike the non-bidi common suite which excludes them) so it needs :common_alert as an explicit dep.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Continues the Python Bazel target granularity work (P2c + P2f):
P2c —
alert.py: Extracted into//py:common_alert. Lazy-importedAlertinswitch_to.py(method body) and moved it toTYPE_CHECKINGinexpected_conditions.pyso neither//py:remotenor//py:supportcarries the compile-time dep. Groupedalerts_tests.py+webdriverwait_tests.pyinto a sharedALERT_TESTSsub-suite (both calldriver.switch_to.alertat runtime, requiring:common_alertin runfiles).P2f —
color.py: Extracted into//py:support_color(no source changes needed —rendered_webelement_tests.pyis the only browser test importingColor). Removedcolor.pyfrom//py:supportglob.Both groups are added to
FEATURE_TESTS(auto-excluded from all*-commonsuites) andFEATURE_SUITE_DEFS, generatingtest-<browser>-alertsandtest-<browser>-renderedsub-suites across all browser/bidi/remote variants.CI impact: changing
alert.pynow only dirtiestest-*-alertstargets; changingcolor.pyonly dirtiestest-*-renderedtargets — instead of all ~700 browser test targets.Test plan
Alertis underTYPE_CHECKINGwithfrom __future__ import annotationsin both modified filestest-chrome-alertsrunsalerts_tests.py+webdriverwait_tests.py(requires:common_alert)test-chrome-renderedrunsrendered_webelement_tests.py(requires:support_color)test-chrome-commonno longer includes the above test files//py:seleniumincludes both new libraries