简体   繁体   中英

Python/Selenium not switching pages for Chrome 78 when executing Javascript

I have a script that switches site pages that contains tables. It have worked fine for months (last time with Chrome version 76), but after the installation of new Chrome version 78.0.3904.70 an error has been set:

        driver.execute_script("__doPostBack('action','Page${}')".format(page))

      File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 636, in execute_script
        'args': converted_args})['value']

      File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
        self.error_handler.check_response(response)

      File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)

    JavascriptException: javascript error: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
      (Session info: chrome=78.0.3904.70)

I've used the command driver.execute_script("__doPostBack('action','Page${}')".format(page)) to switch the pages. I've searched and tryed by solutions using "value" but nothing worked.

I searched for chuncks of the messages 'args': converted_args})['value'] and

JavascriptException: javascript error: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
  (Session info: chrome=78.0.3904.70)

but none was helpful.

My Python version is 3.6 and Chromedriver version 78.0.3904.70. Windows 10 x64

Actually, something like this might work:

el = driver.execute_script("""
  return document.querySelector('[onclick*="Page${}"]')
"""
el.click()

Try to update your selenium dependency, may you are using old dependencies of selenium which is causing the issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM