diff --git a/examples/cdp_mode/ReadMe.md b/examples/cdp_mode/ReadMe.md index d62ba379dac..3e29e8362de 100644 --- a/examples/cdp_mode/ReadMe.md +++ b/examples/cdp_mode/ReadMe.md @@ -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) diff --git a/mkdocs_build/requirements.txt b/mkdocs_build/requirements.txt index e892f4d8ea7..dd291497837 100644 --- a/mkdocs_build/requirements.txt +++ b/mkdocs_build/requirements.txt @@ -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 diff --git a/requirements.txt b/requirements.txt index ca6392f15b7..e87cf6ca55f 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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 @@ -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" diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 303a13da21b..70dd646a52f 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.41.3" +__version__ = "4.41.4" diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 4e2866c9b80..e72614a8ac0 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -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 diff --git a/seleniumbase/core/sb_cdp.py b/seleniumbase/core/sb_cdp.py index a6f39c2d810..e813202ef11 100644 --- a/seleniumbase/core/sb_cdp.py +++ b/seleniumbase/core/sb_cdp.py @@ -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 diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index 8d69bc714a9..639f9c06f91 100644 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -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, @@ -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, diff --git a/setup.py b/setup.py index ec22c2b2503..4bf61871ab6 100755 --- a/setup.py +++ b/setup.py @@ -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', @@ -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"', ], @@ -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", ],