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] Add page load strategy enum #13258

Merged
merged 3 commits into from Dec 8, 2023

Conversation

M1troll
Copy link
Contributor

@M1troll M1troll commented Dec 7, 2023

Description

Add PageLoadStrategy to get rid of writing the webdriver's page load strategy manually.

Motivation and Context

Fixes issue#13236:

Hi!

In my project, I've encountered a situation where I need to change the default page load strategy, but the only way to find the names of the available strategies is by searching the documentation or looking at the descriptor implementation.

I think it would be convenient to have an enum for these names. This would help with hints of available strategy names and save us from having to remember their full names. It would also be great to add info about difference between these strategies in the docstring of this class, as is done in the documentation.

Thanks!

Usage example

If enum is named PageLoadStrategy, I can easily use strategy name as follows:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options, PageLoadStrategy

options = Options()
options.page_load_strategy = PageLoadStrategy.EAGER

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. -> normal, eager, none for Python
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@M1troll M1troll marked this pull request as ready for review December 7, 2023 05:27
@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2023

Codecov Report

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

Comparison is base (6620bce) 57.95% compared to head (03e7bcc) 57.99%.

❗ Current head 03e7bcc differs from pull request most recent head 70bc6c2. Consider uploading reports for the commit 70bc6c2 to get more accurate results

Files Patch % Lines
py/selenium/webdriver/common/options.py 83.33% 1 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #13258      +/-   ##
==========================================
+ Coverage   57.95%   57.99%   +0.03%     
==========================================
  Files          88       88              
  Lines        5333     5338       +5     
  Branches      224      224              
==========================================
+ Hits         3091     3096       +5     
  Misses       2018     2018              
  Partials      224      224              

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

@M1troll M1troll force-pushed the add-enum-for-page-load-strategies branch 2 times, most recently from 70bbc90 to 46b32e9 Compare December 7, 2023 06:12
@M1troll M1troll force-pushed the add-enum-for-page-load-strategies branch from 46b32e9 to 3836951 Compare December 7, 2023 06:19
@isaulv
Copy link
Contributor

isaulv commented Dec 8, 2023

One concern I have is that enum string objects remain Enums until a json library parses it as a string object. But if tests pass, this is fine.

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, @M1troll!

Thank you for reviewing, @isaulv!

@diemol diemol merged commit 68b9260 into SeleniumHQ:trunk Dec 8, 2023
14 checks passed
@titusfortner
Copy link
Member

@isaulv do you have specific code recommendation for that?

@isaulv
Copy link
Contributor

isaulv commented Dec 8, 2023

@titusfortner the enum object is fine so long it gets ran through a JSON converter. If it doesn't, and that caps object is used in some other context it may not work right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🚀 Feature]: Add enum for _PageLoadStrategyDescriptor
5 participants