
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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")