- 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 perform back and refresh in a browser in Selenium with python?
We can perform back and refresh in the browser in Selenium.
For performing back operation in the browser, the back method is to be used.
For refreshing the browser, refresh method is to be used.
Both these methods can be used for testing browser navigations and reloading of web pages.
Example
Code Implementation
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/index.htm") # to print the page title in console print(driver.title) # to print the current URL in console print(driver.current_url) #get method to launch another URL driver.get("https://www.tutorialspoint.com/questions/index.php") # to go back to the previous URL driver.back() #to refresh the browser driver.refresh() #to close the browser driver.close()
- Related Articles
- How to refresh a browser then navigate to a new page with Javascript executor in Selenium with python?
- How to perform browser navigations in Selenium?
- How to close a browser session in Selenium with python?
- How to perform drag and drop operation in Selenium with python?
- How to invoke the Chrome browser in Selenium with python?
- How to invoke the Firefox browser in Selenium with python?
- How to invoke the IE browser in Selenium with python?
- How to refresh a webpage using Python Selenium Webdriver?
- How to perform releasing a mouse on an element in Selenium with python?
- How to perform mouse movement to an element in Selenium with python?
- How to perform vertical scrolling of a webpage with Javascript executor in Selenium with python?
- How to start selenium browser with proxy?
- How to perform double click on an element in Selenium with python?
- How to perform right click on an element in Selenium with python?
- How to disable browser's back button with JavaScript?

Advertisements