- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set Selenium Python WebDriver default timeout?
We can set default timeout with Selenium webdriver. The method set_page_load_timeout is used to have a timeout for the page loading. The wait time in seconds is passed as parameter to the method.
Syntax
driver.set_page_load_timeout(5)
A TimeoutException is thrown if the page is still not loaded after the wait time is passed.
We can use the implicit wait concept in synchronization to define the default timeout time. This is a global wait time and applied to every element in the page. The method implicitly_wait is used to define implicit wait. The wait time in seconds is passed as parameter to the method.
Syntax
driver.implicitly_wait(5);
A TimeoutException is thrown if the page is still not loaded after the implicit wait time is passed.
Example
Code Implementation with set_page_load_timeout()
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # set_page_load_timeout to set the default page load time driver.set_page_load_timeout(0.8) driver.get("https://www.tutorialspoint.com/index.htm")
Code Implementation with implicit wait.
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") #implicit wait of 0.8 seconds applied driver.implicitly_wait(0.8) driver.get("https://www.tutorialspoint.com/index.htm")
- Related Articles
- How do I set the Selenium webdriver get timeout?
- How to set Page Load Timeout using C# using Selenium WebDriver?
- Set up a real timeout for loading page in Selenium WebDriver?
- How to set window size using phantomjs and selenium webdriver in Python?
- How to switch back from a frame to default in Selenium Webdriver?
- How to set Proxy in Firefox using Selenium WebDriver?
- How to set a cookie to a specific domain in selenium webdriver with Python?
- How install Selenium Webdriver with Python?
- How to set default download directory in selenium Chrome Capabilities?
- How to click on image in selenium webdriver Python?
- How to refresh a webpage using Python Selenium Webdriver?
- How to handle frames in Selenium Webdriver in Python?
- How to set timeout to pyplot.show() in Matplotlib?
- How to get selected option using Selenium WebDriver with Python?
- How to take partial screenshot with Selenium WebDriver in python?
