Answer the question
In order to leave comments, you need to log in
Python+Selenium+PhantomJS. How to implement page wait?
Good afternoon. Can you please tell me how, using this simple code as an example, to implement waiting for the page to load? For example, it waits 20 seconds, and if it doesn’t load, it writes a message and goes to the exit. Thanks in advance.
from selenium import webdriver
import time
browser=webdriver.PhantomJS()
browser.get('http://yandex.ru')
browser.quit()
Answer the question
In order to leave comments, you need to log in
well, the first link in google is stackoverflow.com/questions/17533024/how-to-set-se...
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
browser = webdriver.PhantomJS()
browser.set_page_load_timeout(30)
try:
browser.get('https://yandex.ru')
except TimeoutException:
print("can't load page")
browser.quit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question