From bdc3ef700180e940a8506848216d41c9d9904157 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sun, 22 Nov 2020 18:28:56 +0100 Subject: [PATCH] Fix _make_sizzle_string The github action runs on python 3.7. From the python docs: ``` Changed in version 3.7: Only characters that can have special meaning in a regular expression are escaped. As a result, '!', '"', '%', "'", ',', '/', ':', ';', '<', '=', '>', '@', and "`" are no longer escaped. ``` --- lib/galaxy/selenium/sizzle.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/selenium/sizzle.py b/lib/galaxy/selenium/sizzle.py index a392a954916..172c6ac7ca2 100644 --- a/lib/galaxy/selenium/sizzle.py +++ b/lib/galaxy/selenium/sizzle.py @@ -1,6 +1,6 @@ """Utilities for using sizzle (jQuery-style) selectors with Selenium.""" -import re +import json from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.ui import WebDriverWait @@ -119,11 +119,9 @@ def _is_sizzle_loaded(driver): def _make_sizzle_string(sizzle_selector): - try: - selector = sizzle_selector.decode("utf-8") - except (AttributeError, UnicodeEncodeError): - selector = sizzle_selector - return "return Sizzle(\"{selector}\");".format(selector=re.escape(selector)) + # Use json.dumps to escape quotes + selector = json.dumps(sizzle_selector) + return f"return Sizzle({selector});" __all__ = (