
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
Common Driver Methods for Browsers in Selenium with Python
There are multiple common web driver methods that allow operation on browsers in Selenium with Python. Some of these methods are listed below −
-
driver.get(url)
This method is used to navigate or launch a new URL. The webdriver waits until there is full page load. For an application that has AJAX code, the web driver remains unaware about complete loading of the page. Thus for these situations we need to use waits.
-
driver.maximize_window()
This method is used to maximize the active window that is interacting with the web driver.
-
driver.minimize_window()
This method is used to minimize the active window that is interacting with the web driver.
-
driver.back()
This method is used to move to a single step back in the history of browsers.
-
driver.forward()
This method is used to move to a single step forward in the history of browsers.
-
driver.refresh()
This method is used to refresh the current page.
Example
Code Implementation with browser methods.
from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke #actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/about/about_careers.htm") #to maximize the browser driver.maximize_window() #to refresh the browser driver.refresh() #get method to launch another URL driver.get("https://www.tutorialspoint.com/index.htm") #to minimize the browser driver.minimize_window() #to move one step back in browser history driver.back() #to move one step forward in browser history driver.forward() #to close the browser driver.close()