How to stop a page loading from selenium in chrome?

0 votes

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

Thank u in advance!!

Jul 2 in Selenium by savan
• 120 points

edited Jul 2 by Niroj 152 views

3 answers to this question.

0 votes
answered Jul 2 by Niroj
• 41,480 points
0 votes

Hey @Savan, 

Have you tried with setting up page load strategy in your selenium capabilities?

You can stop a page from loading by setting the pageLoadStrategy capability to none

Hope this helps!

answered Jul 3 by Sirajul
• 55,220 points
0 votes

Hi Savan,

Setting the pageLoadStrategy capability to none. Then wait for an 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();")


Thanks,hope my answer will help .

answered Jul 6 by Suhana

edited Jul 6

Related Questions In Selenium

0 votes
1 answer

How to choose from a drop-down in Selenium 2?

You can probably use the 'Select' class ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,710 points
310 views
0 votes
1 answer

How to replace remote resources with local resource in a page with Selenium?

You could change URL for that script ...READ MORE

answered Aug 8, 2018 in Selenium by Samarpit
• 5,890 points
256 views
0 votes
5 answers
0 votes
1 answer

How to use a specific chrome profile in selenium?

User profiling is the term used for ...READ MORE

answered Dec 24, 2018 in Selenium by Shuvodip
9,180 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,170 views
0 votes
0 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,078 views
+2 votes
1 answer

How to fetch the text of a web element where the text is split in 2 lines?

Hello, You want to use a non-breaking space ...READ MORE

answered May 28 in Selenium by Niroj
• 41,480 points
165 views
0 votes
1 answer

How to Handle alerts like Irctc alert in selenium?

Hello  karthik, Handling alerts manually is a tedious task. ...READ MORE

answered Jun 29 in Selenium by Niroj
• 41,480 points
82 views