Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d788616

Browse files
authored
Merge pull request #3959 from seleniumbase/more-select-options-for-cdp-mode
Add more select options for CDP Mode
2 parents ae9021d + 8c4629f commit d788616

File tree

8 files changed

+50
-9
lines changed

8 files changed

+50
-9
lines changed

‎examples/cdp_mode/ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ sb.cdp.mouse_click(selector, timeout=None)
399399
sb.cdp.nested_click(parent_selector, selector)
400400
sb.cdp.get_nested_element(parent_selector, selector)
401401
sb.cdp.select_option_by_text(dropdown_selector, option)
402+
sb.cdp.select_option_by_index(dropdown_selector, option)
403+
sb.cdp.select_option_by_value(dropdown_selector, option)
402404
sb.cdp.flash(selector, duration=1, color="44CC88", pause=0)
403405
sb.cdp.highlight(selector)
404406
sb.cdp.focus(selector)

‎mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mkdocs dependencies for generating the seleniumbase.io website
22
# Minimum Python version: 3.9 (for generating docs only)
33

4-
regex>=2025.7.34
4+
regex>=2025.9.1
55
pymdown-extensions>=10.16.1
66
pipdeptree>=2.28.0
77
python-dateutil>=2.8.2

‎requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ iniconfig==2.1.0
5656
pluggy==1.5.0;python_version<"3.9"
5757
pluggy==1.6.0;python_version>="3.9"
5858
pytest==8.3.5;python_version<"3.9"
59-
pytest==8.4.1;python_version>="3.9"
59+
pytest==8.4.2;python_version>="3.9"
6060
pytest-html==4.0.2
6161
pytest-metadata==3.1.1
6262
pytest-ordering==0.6
6363
pytest-rerunfailures==14.0;python_version<"3.9"
64-
pytest-rerunfailures==15.1;python_version>="3.9"
64+
pytest-rerunfailures==16.0.1;python_version>="3.9"
6565
pytest-xdist==3.6.1;python_version<"3.9"
6666
pytest-xdist==3.8.0;python_version>="3.9"
6767
parameterized==0.9.0
@@ -80,7 +80,7 @@ rich>=14.1.0,<15
8080
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
8181

8282
coverage>=7.6.1;python_version<"3.9"
83-
coverage>=7.10.5;python_version>="3.9"
83+
coverage>=7.10.6;python_version>="3.9"
8484
pytest-cov>=5.0.0;python_version<"3.9"
8585
pytest-cov>=6.2.1;python_version>="3.9"
8686
flake8==5.0.4;python_version<"3.9"

‎seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.41.3"
2+
__version__ = "4.41.4"

‎seleniumbase/core/browser_launcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
808808
cdp.get_window_size = CDPM.get_window_size
809809
cdp.nested_click = CDPM.nested_click
810810
cdp.select_option_by_text = CDPM.select_option_by_text
811+
cdp.select_option_by_index = CDPM.select_option_by_index
812+
cdp.select_option_by_value = CDPM.select_option_by_value
811813
cdp.flash = CDPM.flash
812814
cdp.highlight = CDPM.highlight
813815
cdp.focus = CDPM.focus

‎seleniumbase/core/sb_cdp.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,37 @@ def select_option_by_text(self, dropdown_selector, option):
823823
% (dropdown_selector, option)
824824
)
825825

826+
def select_option_by_index(self, dropdown_selector, option):
827+
element = self.find_element(dropdown_selector)
828+
element.scroll_into_view()
829+
options = element.query_selector_all("option")
830+
count = 0
831+
for found_option in options:
832+
if count == int(option):
833+
found_option.select_option()
834+
return
835+
count += 1
836+
raise Exception(
837+
"Unable to find index option {%s} in dropdown {%s}!"
838+
% (dropdown_selector, option)
839+
)
840+
841+
def select_option_by_value(self, dropdown_selector, option):
842+
element = self.find_element(dropdown_selector)
843+
element.scroll_into_view()
844+
options = element.query_selector_all("option")
845+
for found_option in options:
846+
if (
847+
"value" in found_option.attrs
848+
and str(found_option.attrs["value"]) == str(option)
849+
):
850+
found_option.select_option()
851+
return
852+
raise Exception(
853+
"Unable to find value option {%s} in dropdown {%s}!"
854+
% (dropdown_selector, option)
855+
)
856+
826857
def flash(
827858
self,
828859
selector, # The CSS Selector to flash

‎seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,6 +3198,9 @@ def select_option_by_index(
31983198
timeout = settings.SMALL_TIMEOUT
31993199
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
32003200
timeout = self.__get_new_timeout(timeout)
3201+
if self.__is_cdp_swap_needed():
3202+
self.cdp.select_option_by_index(dropdown_selector, option)
3203+
return
32013204
self.__select_option(
32023205
dropdown_selector,
32033206
option,
@@ -3222,6 +3225,9 @@ def select_option_by_value(
32223225
timeout = settings.SMALL_TIMEOUT
32233226
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
32243227
timeout = self.__get_new_timeout(timeout)
3228+
if self.__is_cdp_swap_needed():
3229+
self.cdp.select_option_by_value(dropdown_selector, option)
3230+
return
32253231
self.__select_option(
32263232
dropdown_selector,
32273233
option,

‎setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@
204204
'pluggy==1.5.0;python_version<"3.9"',
205205
'pluggy==1.6.0;python_version>="3.9"',
206206
'pytest==8.3.5;python_version<"3.9"',
207-
'pytest==8.4.1;python_version>="3.9"',
207+
'pytest==8.4.2;python_version>="3.9"',
208208
"pytest-html==4.0.2", # Newer ones had issues
209209
'pytest-metadata==3.1.1',
210210
"pytest-ordering==0.6",
211211
'pytest-rerunfailures==14.0;python_version<"3.9"',
212-
'pytest-rerunfailures==15.1;python_version>="3.9"',
212+
'pytest-rerunfailures==16.0.1;python_version>="3.9"',
213213
'pytest-xdist==3.6.1;python_version<"3.9"',
214214
'pytest-xdist==3.8.0;python_version>="3.9"',
215215
'parameterized==0.9.0',
@@ -237,7 +237,7 @@
237237
# Usage: coverage run -m pytest; coverage html; coverage report
238238
"coverage": [
239239
'coverage>=7.6.1;python_version<"3.9"',
240-
'coverage>=7.10.5;python_version>="3.9"',
240+
'coverage>=7.10.6;python_version>="3.9"',
241241
'pytest-cov>=5.0.0;python_version<"3.9"',
242242
'pytest-cov>=6.2.1;python_version>="3.9"',
243243
],
@@ -270,7 +270,7 @@
270270
'pdfminer.six==20250324;python_version<"3.9"',
271271
'pdfminer.six==20250506;python_version>="3.9"',
272272
'cryptography==39.0.2;python_version<"3.9"',
273-
'cryptography==45.0.6;python_version>="3.9"',
273+
'cryptography==45.0.7;python_version>="3.9"',
274274
'cffi==1.17.1',
275275
"pycparser==2.22",
276276
],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /