question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

[šŸ› Bug]: Selenium pauses execution of code when using Remote DevTools

See original GitHub issue

What happened?

Iā€™m launching an instance of ChromeDriver with the remote debugging port option set and I can access the remote dev tools just fine however whenever I do, the script just pauses execution and sits there on the page. There are no errors in the console or in the browser and there are no indicators that anything has gone wrong. One oddity I noticed was that if I repeatedly scroll up and down on the page, the script will continue so long as I continue scrolling.

This issue has already been reported here (#9759) but lacked details so I figured Iā€™d open a new issue. Iā€™m not really sure what to make of all this or even where I should post this issue so Iā€™m just starting here. Iā€™ll be happy to file an issue elsewhere if someone can point me in the right direction.

Steps to reproduce:

  1. Run the example script below
  2. Go to http://localhost:9000
  3. Click on the React Image Gallery link
  4. Wait a bit and you should not see the script doing anything
  5. Rapidly scroll up and down and the script should continue execution
  6. Stop scrolling and the script should pause

EDIT: You may not have to continuously scroll. I was just able to get the script going again scrolling once in between action. It seems that all it needs is the remote debugger to send it a command/action? Not sure.

How can we reproduce the issue?

from selenium.webdriver.chrome.options import Options
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep


def start_driver():
    chrome_options = Options()
    chrome_options.add_argument("--remote-debugging-port=9000")
    chrome_options.add_argument("--no-sandbox")
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_argument("--disable-gpu")
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-translate")
    chrome_options.add_argument("--disable-extensions")
    chrome_options.add_argument("--disable-background-networking")
    chrome_options.add_argument("--safebrowsing-disable-auto-update")
    chrome_options.add_argument("--disable-sync")
    chrome_options.add_argument("--metrics-recording-only")
    chrome_options.add_argument("--disable-default-apps")
    chrome_options.add_argument("--no-first-run")
    chrome_options.add_argument("--disable-setuid-sandbox")
    chrome_options.add_argument("--hide-scrollbars")
    chrome_options.add_argument("--no-zygote")
    chrome_options.add_argument("--autoplay-policy=no-user-gesture-required")
    chrome_options.add_argument("--disable-notifications")
    chrome_options.add_argument("--disable-logging")
    chrome_options.add_argument("--disable-permissions-api")
    chrome_options.add_argument("--ignore-certificate-errors")
    chrome_options.add_argument("--window-size=1280,720")
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])

    chrome_options.page_load_strategy = "eager"

    capabilities = DesiredCapabilities.CHROME

    return webdriver.Chrome(
        executable_path="SOME_PATH_TO_CHROME",
        options=chrome_options,
        desired_capabilities=capabilities
    )


driver = start_driver()

for _ in range(50):
    driver.get("https://www.linxtion.com/demo/react-image-gallery/")

    sleep(5)

    right_nav = driver.find_element(By.CLASS_NAME, "image-gallery-right-nav")

    for _ in range(5):
        right_nav.click()

        sleep(2)

Relevant log output

There is none. As far as Selenium is concerned, everything is still operating nominally.

Operating System

Windows 10

Selenium version

Python 4.0.0

What are the browser(s) and version(s) where you see this issue?

Chrome 95

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 95.0.4638

Are you using Selenium Grid?

No

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KasimAhmiccommented, Jan 5, 2022

Yeah, thereā€™s nothing for Selenium to change. Selenium is sending the correct commands to the driver. If the correct thing isnā€™t happening in a given configuration, itā€™s because the driver isnā€™t handling it.

Understood. For anyone else who comes across this issue, Iā€™ve opened a ticket with the ChromeDriver team here: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3986

1reaction
titusfortnercommented, Jan 5, 2022

Yeah, thereā€™s nothing for Selenium to change. Selenium is sending the correct commands to the driver. If the correct thing isnā€™t happening in a given configuration, itā€™s because the driver isnā€™t handling it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to use the Chrome's devtools when running with ...
I am seeking a way to use the chrome's devtools parallel in order to debug my code. Does someone know a way to...
Read more >
ChromeDriver randomly "freezes" for 70-90 seconds, causing ...
Please try the following: 1) Look in the system event log to see if there are any relevant events at the time that...
Read more >
How to Debug Cypress Tests : Tutorial | BrowserStack
Learn 5 ways on how to debug Cypress tests with examples and code snippets. ... Readable error messages; The option to pause test...
Read more >
What's New In DevTools (Chrome 105)
Developer advocate working on Chrome DevTools at Google. ... Replay your user flow, the replay will pause before executing the step. From ......
Read more >
Chrome DevTools - Selenium
While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), it is highly encouraged that you use the WebDriver Bidi APIsĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found