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 3, 2020 in Selenium by savan
• 120 points

edited Jul 3, 2020 by Niroj 7,099 views

3 answers to this question.

0 votes
answered Jul 3, 2020 by Niroj
• 82,840 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, 2020 by Sirajul
• 59,230 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('https://www.edureka.co/')

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 7, 2020 by Suhana

edited Jul 7, 2020

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
1,152 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,910 points
4,697 views
0 votes
8 answers

How to open a link in new tab of chrome browser using Selenium WebDriver?

This below code works for me in ...READ MORE

answered Dec 14, 2020 in Selenium by Gitika
• 65,770 points
103,022 views
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
26,760 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,673 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, 2020 in Selenium by Niroj
• 82,840 points
4,417 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, 2020 in Selenium by Niroj
• 82,840 points
2,888 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP