Subscribe Us

How To Enter The URL In Selenium Webdriver

.
Question : How To Navigate a URL In Selenium Webdriver using java ?

Answer:
In selenium there are 2 method to navigate the url in selenium webdriver 
1) get() method
2) navaigate().to() method 

1) get();
Get method in selenium is used to enter the url.

Syntax
get();

Example 
driver.get("https://www.facebook.com/");

Selenium Code to navigate a URL using get() method 
get()


package automation;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class GetMethod 
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Software\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
}
}

2) navigate().to();
navigate().to() method in selenium is also used to enter the url.

Syntax
navigate().to();

Example 

driver.navigate().to("https://www.facebook.com/");

Selenium Code to navigate a URL Using navigate().to method

navigate().to()


package automation;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ClickMethod
{
public static void main(String[] args)
 {      System.setProperty("webdriver.chrome.driver""C:\\Software\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.navigate().to("https://www.facebook.com/");
}
}

In this tutorial we learn how to  enter the URL in selenium webdriver .Hope this tutorial helpful for you 😊

Thanks & Regards 

Sandeep Yadav

Important Tags : how to navigate url in selenium webdriver , how to enter the url in selenium webdriver using java , how to enter the url in selenium .


How To Enter The URL In Selenium Webdriver 



Post a Comment

0 Comments