I'm using undetected_chromedriver and trying to stop the page loading, but the code stops when I call execute_script("window.stop();") and waits for the page to finish loading. The code is still waiting for the page to finish loading.
Code:
import undetected_chromedriver as uc
from selenium_stealth import stealth
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import os
path_to_driver = os.path.abspath('chromedriver.exe')
options = uc.ChromeOptions()
capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"
driver = uc.Chrome(options=options, executable_path=path_to_driver, use_subprocess=True, desired_capabilities=capa)
stealth(driver,
languages=["en-US", "en"],
vendor="Google Inc.",
platform="Win64",
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=True)
driver.maximize_window()
driver.get("https://coinsniper.net")
time.sleep(5)
print("start")
driver.execute_script("window.stop();")
print("stop")
In this code, after calling driver.get("https://coinsniper.net") the "start" message will be displayed in the console after 5 seconds, then the code will wait until the page is loaded and display the "stop" message. The code performs all functions that do not interact with the driver while the page is loading. But when interacting with the driver no functions are executed, that's the problem. I will be grateful for any advice.