Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/cdp_mode/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ sb.cdp.mouse_click(selector, timeout=None)
sb.cdp.nested_click(parent_selector, selector)
sb.cdp.get_nested_element(parent_selector, selector)
sb.cdp.select_option_by_text(dropdown_selector, option)
sb.cdp.select_option_by_index(dropdown_selector, option)
sb.cdp.select_option_by_value(dropdown_selector, option)
sb.cdp.flash(selector, duration=1, color="44CC88", pause=0)
sb.cdp.highlight(selector)
sb.cdp.focus(selector)
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# mkdocs dependencies for generating the seleniumbase.io website
# Minimum Python version: 3.9 (for generating docs only)

regex>=2025.7.34
regex>=2025.9.1
pymdown-extensions>=10.16.1
pipdeptree>=2.28.0
python-dateutil>=2.8.2
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ iniconfig==2.1.0
pluggy==1.5.0;python_version<"3.9"
pluggy==1.6.0;python_version>="3.9"
pytest==8.3.5;python_version<"3.9"
pytest==8.4.1;python_version>="3.9"
pytest==8.4.2;python_version>="3.9"
pytest-html==4.0.2
pytest-metadata==3.1.1
pytest-ordering==0.6
pytest-rerunfailures==14.0;python_version<"3.9"
pytest-rerunfailures==15.1;python_version>="3.9"
pytest-rerunfailures==16.0.1;python_version>="3.9"
pytest-xdist==3.6.1;python_version<"3.9"
pytest-xdist==3.8.0;python_version>="3.9"
parameterized==0.9.0
Expand All @@ -80,7 +80,7 @@ rich>=14.1.0,<15
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

coverage>=7.6.1;python_version<"3.9"
coverage>=7.10.5;python_version>="3.9"
coverage>=7.10.6;python_version>="3.9"
pytest-cov>=5.0.0;python_version<"3.9"
pytest-cov>=6.2.1;python_version>="3.9"
flake8==5.0.4;python_version<"3.9"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.41.3"
__version__ = "4.41.4"
2 changes: 2 additions & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
cdp.get_window_size = CDPM.get_window_size
cdp.nested_click = CDPM.nested_click
cdp.select_option_by_text = CDPM.select_option_by_text
cdp.select_option_by_index = CDPM.select_option_by_index
cdp.select_option_by_value = CDPM.select_option_by_value
cdp.flash = CDPM.flash
cdp.highlight = CDPM.highlight
cdp.focus = CDPM.focus
Expand Down
31 changes: 31 additions & 0 deletions seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,37 @@ def select_option_by_text(self, dropdown_selector, option):
% (dropdown_selector, option)
)

def select_option_by_index(self, dropdown_selector, option):
element = self.find_element(dropdown_selector)
element.scroll_into_view()
options = element.query_selector_all("option")
count = 0
for found_option in options:
if count == int(option):
found_option.select_option()
return
count += 1
raise Exception(
"Unable to find index option {%s} in dropdown {%s}!"
% (dropdown_selector, option)
)

def select_option_by_value(self, dropdown_selector, option):
element = self.find_element(dropdown_selector)
element.scroll_into_view()
options = element.query_selector_all("option")
for found_option in options:
if (
"value" in found_option.attrs
and str(found_option.attrs["value"]) == str(option)
):
found_option.select_option()
return
raise Exception(
"Unable to find value option {%s} in dropdown {%s}!"
% (dropdown_selector, option)
)

def flash(
self,
selector, # The CSS Selector to flash
Expand Down
6 changes: 6 additions & 0 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,9 @@ def select_option_by_index(
timeout = settings.SMALL_TIMEOUT
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
if self.__is_cdp_swap_needed():
self.cdp.select_option_by_index(dropdown_selector, option)
return
self.__select_option(
dropdown_selector,
option,
Expand All @@ -3222,6 +3225,9 @@ def select_option_by_value(
timeout = settings.SMALL_TIMEOUT
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
if self.__is_cdp_swap_needed():
self.cdp.select_option_by_value(dropdown_selector, option)
return
self.__select_option(
dropdown_selector,
option,
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@
'pluggy==1.5.0;python_version<"3.9"',
'pluggy==1.6.0;python_version>="3.9"',
'pytest==8.3.5;python_version<"3.9"',
'pytest==8.4.1;python_version>="3.9"',
'pytest==8.4.2;python_version>="3.9"',
"pytest-html==4.0.2", # Newer ones had issues
'pytest-metadata==3.1.1',
"pytest-ordering==0.6",
'pytest-rerunfailures==14.0;python_version<"3.9"',
'pytest-rerunfailures==15.1;python_version>="3.9"',
'pytest-rerunfailures==16.0.1;python_version>="3.9"',
'pytest-xdist==3.6.1;python_version<"3.9"',
'pytest-xdist==3.8.0;python_version>="3.9"',
'parameterized==0.9.0',
Expand Down Expand Up @@ -237,7 +237,7 @@
# Usage: coverage run -m pytest; coverage html; coverage report
"coverage": [
'coverage>=7.6.1;python_version<"3.9"',
'coverage>=7.10.5;python_version>="3.9"',
'coverage>=7.10.6;python_version>="3.9"',
'pytest-cov>=5.0.0;python_version<"3.9"',
'pytest-cov>=6.2.1;python_version>="3.9"',
],
Expand Down Expand Up @@ -270,7 +270,7 @@
'pdfminer.six==20250324;python_version<"3.9"',
'pdfminer.six==20250506;python_version>="3.9"',
'cryptography==39.0.2;python_version<"3.9"',
'cryptography==45.0.6;python_version>="3.9"',
'cryptography==45.0.7;python_version>="3.9"',
'cffi==1.17.1',
"pycparser==2.22",
],
Expand Down