How to stop a page loading from selenium in chrome?

selenium

In python ,How to stop a page loading from selenium in chrome? Some pages wont just stop loading.

Thank u in advance!!


If you want to unleash your potential in this competitive field, please visit the selenium course page for more information, where you can find the selenium tutorials and selenium frequently asked interview questions and answers as well.

1
Answers

Replies

In order to stop a page loading from selenium in chrome, you will need to set the pageLoadStrategy to none. You will also need to wait for the element to be present and call window.stop to stop the loading.



from selenium import webdriver

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.by import By


capa = DesiredCapabilities.CHROME

capa["pageLoadStrategy"] = "none"


driver = webdriver.Chrome(desired_capabilities=capa)

wait = WebDriverWait(driver, 20)


driver.get('http://xyz.com/')


wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#h-top-questions')))


driver.execute_script("window.stop();")
 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top