From 3c8ffe3a883564fac400f123e4ac323c52b8fc19 Mon Sep 17 00:00:00 2001 From: Ed Manlove Date: Sun, 3 Aug 2025 19:35:33 -0400 Subject: [PATCH 1/2] Corrected expected plugin doc with changes to screenshot embed --- ...luginDocumentation.test_parse_plugin_init_doc.approved.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt b/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt index 935242b1e..3d734ab87 100644 --- a/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt +++ b/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt @@ -7,8 +7,8 @@ SeleniumLibrary can be imported with several optional arguments. - ``run_on_failure``: Default action for the `run-on-failure functionality`. - ``screenshot_root_directory``: - Path to folder where possible screenshots are created or EMBED. - See `Set Screenshot Directory` keyword for further details about EMBED. + Path to folder where possible screenshots are created or EMBED or BASE64. + See `Set Screenshot Directory` keyword for further details about EMBED and BASE64. If not given, the directory where the log file is written is used. - ``plugins``: Allows extending the SeleniumLibrary with external Python classes. From e361743a90f5c423bf78aef214153be03c84e3b7 Mon Sep 17 00:00:00 2001 From: Ed Manlove Date: Sun, 3 Aug 2025 19:37:05 -0400 Subject: [PATCH 2/2] Removed and replaced deprecated is_string method --- src/SeleniumLibrary/__init__.py | 3 +-- src/SeleniumLibrary/keywords/window.py | 4 ++-- src/SeleniumLibrary/locators/windowmanager.py | 11 +++++------ src/SeleniumLibrary/utils/__init__.py | 1 - src/SeleniumLibrary/utils/types.py | 4 ++-- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/SeleniumLibrary/__init__.py b/src/SeleniumLibrary/__init__.py index 82ee75e5d..3994c1ccc 100644 --- a/src/SeleniumLibrary/__init__.py +++ b/src/SeleniumLibrary/__init__.py @@ -24,7 +24,6 @@ from robot.api import logger from robot.errors import DataError from robot.libraries.BuiltIn import BuiltIn -from robot.utils import is_string from robot.utils.importer import Importer from robotlibcore import DynamicCore @@ -843,7 +842,7 @@ def _store_plugin_keywords(self, plugin): def _resolve_screenshot_root_directory(self): screenshot_root_directory = self.screenshot_root_directory - if is_string(screenshot_root_directory): + if isinstance(screenshot_root_directory, str): if screenshot_root_directory.upper() == EMBED: self.screenshot_root_directory = EMBED if screenshot_root_directory.upper() == BASE64: diff --git a/src/SeleniumLibrary/keywords/window.py b/src/SeleniumLibrary/keywords/window.py index 01feee1fe..f2b086223 100644 --- a/src/SeleniumLibrary/keywords/window.py +++ b/src/SeleniumLibrary/keywords/window.py @@ -21,7 +21,7 @@ from SeleniumLibrary.base import keyword, LibraryComponent from SeleniumLibrary.locators import WindowManager -from SeleniumLibrary.utils import plural_or_not, is_string +from SeleniumLibrary.utils import plural_or_not class WindowKeywords(LibraryComponent): @@ -117,7 +117,7 @@ def switch_window( except NoSuchWindowException: pass finally: - if not is_string(browser) or not browser.upper() == "CURRENT": + if not isinstance(browser, str) or not browser.upper() == "CURRENT": self.drivers.switch(browser) self._window_manager.select(locator, timeout) diff --git a/src/SeleniumLibrary/locators/windowmanager.py b/src/SeleniumLibrary/locators/windowmanager.py index 1dcff9330..a785babbd 100644 --- a/src/SeleniumLibrary/locators/windowmanager.py +++ b/src/SeleniumLibrary/locators/windowmanager.py @@ -21,7 +21,6 @@ from SeleniumLibrary.base import ContextAware from SeleniumLibrary.errors import WindowNotFound -from SeleniumLibrary.utils import is_string WindowInfo = namedtuple("WindowInfo", "handle, id, name, title, url") @@ -38,7 +37,7 @@ def __init__(self, ctx): } def get_window_handles(self, browser): - if is_string(browser) and browser == "ALL": + if isinstance(browser, str) and browser == "ALL": handles = [] current_index = self.drivers.current_index for index, driver in enumerate(self.drivers, 1): @@ -46,7 +45,7 @@ def get_window_handles(self, browser): handles.extend(self.driver.window_handles) self.drivers.switch(current_index) return handles - elif is_string(browser) and browser == "CURRENT": + elif isinstance(browser, str) and browser == "CURRENT": return self.driver.window_handles else: current_index = self.drivers.current_index @@ -60,14 +59,14 @@ def get_window_infos(self, browser="CURRENT"): current_index = self.drivers.current_index except AttributeError: current_index = None - if is_string(browser) and browser.upper() == "ALL": + if isinstance(browser, str) and browser.upper() == "ALL": infos = [] for index, driver in enumerate(self.drivers, 1): self.drivers.switch(index) infos.extend(self._get_window_infos()) self.drivers.switch(current_index) return infos - elif is_string(browser) and browser.upper() == "CURRENT": + elif isinstance(browser, str) and browser.upper() == "CURRENT": return self._get_window_infos() else: self.drivers.switch(browser) @@ -100,7 +99,7 @@ def select(self, locator, timeout=0): time.sleep(0.1) def _select(self, locator): - if not is_string(locator): + if not isinstance(locator, str): self._select_by_excludes(locator) elif locator.upper() == "CURRENT": pass diff --git a/src/SeleniumLibrary/utils/__init__.py b/src/SeleniumLibrary/utils/__init__.py index ccc4df2c6..68ba94e1b 100644 --- a/src/SeleniumLibrary/utils/__init__.py +++ b/src/SeleniumLibrary/utils/__init__.py @@ -20,7 +20,6 @@ from .types import ( is_falsy, is_noney, - is_string, is_truthy, WINDOWS, _convert_timeout, diff --git a/src/SeleniumLibrary/utils/types.py b/src/SeleniumLibrary/utils/types.py index 82a94ada5..181b0bf50 100644 --- a/src/SeleniumLibrary/utils/types.py +++ b/src/SeleniumLibrary/utils/types.py @@ -17,7 +17,7 @@ from datetime import timedelta from typing import Any -from robot.utils import is_string, timestr_to_secs +from robot.utils import timestr_to_secs from robot.utils import is_truthy, is_falsy # noqa # Need only for unit tests and can be removed when Approval tests fixes: @@ -26,7 +26,7 @@ def is_noney(item): - return item is None or is_string(item) and item.upper() == "NONE" + return item is None or isinstance(item, str) and item.upper() == "NONE" def _convert_delay(delay): if isinstance(delay, timedelta):