Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

wait for page to load selenium python

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException

browser = webdriver.Firefox()
browser.get("url")
delay = 3 # seconds
try:
    myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.ID, 'IdOfMyElement')))
    print "Page is ready!"
except TimeoutException:
    print "Loading took too much time!"
Comment

How to wait a page is loaded in Python Selenium

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
try:
    next_page_elem = self.browser.find_element_by_xpath("//a[text()='%d']" % pageno)

except noSuchElementException:
    break
print('page ', pageno)
next_page_elem.click()

# wait for the page to load
wait.until(
    EC.presence_of_element_located((By.XPATH, "//a[@class = 'on' and . = '%d']" % pageno))
)
Comment

python selenium: does not wait until page is loaded after a click() command

def wait_for_visibility(self, selector, timeout_seconds=10):
    retries = timeout_seconds
    while retries:
        try:
            element = self.get_via_css(selector)
            if element.is_displayed():
                return element
        except (exceptions.NoSuchElementException,
                exceptions.StaleElementReferenceException):
            if retries <= 0:
                raise
            else:
                pass

        retries = retries - 1
        time.sleep(pause_interval)
    raise exceptions.ElementNotVisibleException(
        "Element %s not visible despite waiting for %s seconds" % (
            selector, timeout_seconds)
    )
Comment

PREVIOUS NEXT
Code Example
Python :: python sort list in reverse order 
Python :: import c# dll in python 
Python :: combine date and time python 
Python :: Python program that takes 2 words as input from the user and prints out a list containing the letters that the 2 words have in common 
Python :: python tkinter change label text 
Python :: pandas split train test 
Python :: read csv boto3 
Python :: how to set screen brightness automatically depending on battery percentage using python 
Python :: how to create a cube in ursina 
Python :: array must not contain infs or NaNs 
Python :: pandas write to csv without first line 
Python :: lock window size tkinter 
Python :: matplotlib display axis in scientific notation 
Python :: one matrix with np 
Python :: python tkinter text widget 
Python :: how to type a dict in python 
Python :: f string python not working in linux 
Python :: How to create an efficient median finder for a stream of values, in Python? 
Python :: python pandas convert nan to 0 
Python :: get all indices of a value in list python 
Python :: python class documentation 
Python :: python hex to bytes string 
Python :: how to stop code in ursina 
Python :: confusion matrix from two columns pandas dataframe 
Python :: python list group by count 
Python :: show pandas all data 
Python :: hot to pay music in pygame 
Python :: igraph adjacency matrix python 
Python :: get time between things python 
Python :: print nested list in new lines 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =