

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to perform browser navigations in Selenium?
There are various navigate() methods to perform navigations in Selenium. They are as the listed below −
navigate().to(url)
This is used to launch a new browser and open a particular URL as in the parameter.
navigate().refresh()
This is used to reload a page.
navigate().back()
This is used to jump to the previous page as per browser history context.
navigate().forward()
This is used to jump to the next page as per browser history context.
Example
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class BrowserNavigation { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/index.htm"; // new browser will launch and navigate to the URL driver.navigate().to(url); driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); // refresh the current browser driver.navigate().refresh(); //Using id tagname attribute combination for css expression driver.findElement(By.cssSelector("input[name=’search’]")). sendKeys("Selenium"); //browser will go back to the previous page driver.navigate().back(); //browser will go move to the next page driver.navigate().forward(); driver.close(); } }
- Related Questions & Answers
- How to perform back and refresh in a browser in Selenium with python?
- How to maximize the browser in Selenium?
- How to launch Chrome Browser via Selenium?
- How to start selenium browser with proxy?
- Python selenium browser driver.back().
- Selenium testing without browser.
- How to launch Edge browser with Selenium Webdriver?
- Browser Plugin Testing With Selenium.
- Use Selenium with Chromium Browser.
- Does Selenium support Safari browser?
- Handling Browser Authentication using Selenium
- How does selenium webdriver upload files to the browser?
- How to switch different browser tabs using Python Selenium?
- How to run Selenium tests on Chrome Browser using?
- How to run Selenium tests on Internet Explorer browser?
Advertisements