sukgu / pyshadow

Selenium plugin to manage multi level shadow DOM elements on web page.
Apache License 2.0
46 stars 9 forks source link

CSS with double quotes having single quotes inside not working. #2

Closed sukgu closed 1 year ago

sukgu commented 3 years ago

Describe the bug If we have a CSS like shadow.find_element("div[label='QA']") doesn't work and throws error. The same works fine when we have CSS like shadow.find_element('div[label="QA"]')

To Reproduce Steps to reproduce the behavior:

  1. Write code to find an element with an attribute value like shadow.find_element("div[label='QA']")
  2. Run the code
  3. See error

Expected behavior It should work fine for single quotes and double quotes both.

mweinelt commented 3 years ago

FWIW: The resulting traceback is

Traceback (most recent call last):
  File "/run/current-system/sw/bin/test-runner", line 31, in <module>
    name = shadow.find_element("input[name='name']")
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/multipledispatch/dispatcher.py", line 435, in __call__
    return func(self.obj, *args, **kwargs)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/pyshadow/main.py", line 103, in find_element
    element = self.executor_get_object(command)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/multipledispatch/dispatcher.py", line 435, in __call__
    return func(self.obj, *args, **kwargs)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/pyshadow/main.py", line 78, in executor_get_object
    return self.inject_shadow_executor(javascript)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/multipledispatch/dispatcher.py", line 435, in __call__
    return func(self.obj, *args, **kwargs)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/pyshadow/main.py", line 67, in inject_shadow_executor
    return self.driver.execute_script(javascript)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 634, in execute_script
    return self.execute(command, {
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/nix/store/i70af0zjmlk62jcadrlj2ziwcfvz7ak4-python3-3.8.9-env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: SyntaxError: missing ) after argument list
mweinelt commented 3 years ago

The diff between v0.0.3..v0.0.4 seems unrelated honestly. Or did you tag the wrong git commit?

diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 0376072..f70d0b5 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -10,7 +10,7 @@ on:
 jobs:
   deploy:

-    runs-on: ubuntu-latest
+    runs-on: ubuntu-18.04

     steps:
     - uses: actions/checkout@v2
diff --git a/setup.py b/setup.py
index 73344c5..b97b3d9 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ from setuptools import setup
 setup(
     name='pyshadow',
     description='Selenium plugin to manage shadow DOM elements on web page.',
-    version='0.0.2',
+    version='0.0.3',
     long_description=open("README.md").read(),
     long_description_content_type="text/markdown",
     license="Apache License 2",
sukgu commented 3 years ago

@mweinelt Ohh, yes. My fault. Removed the release. Will update it soon with the fix. Thanks

xuehuachunsheng commented 2 years ago

It seems that both the v0.0.3 and v0.0.4 raise this error. Any solutions?