SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

What is get method in selenium?

WebDriver interface has many different methods and get method is one of them. WebDriver interface is implemented by different browser classes like ChromeDriver, EdgeDriver, EventFiringWebDriver, FirefoxDriver, InternetExplorerDriver, OperaDriver, RemoteWebDriver and SafariDriver. So you can use get method to open any of these browser with given URL syntax.

get Method
  • Method Name : get
  • Method description : Using HTTP GET operation, It will load new web page in current web browser window. It will block all other operations until the browser load is completed. That means, Next syntax will be executed only after browser loaded completely with given URL.
  • Syntax : driver.get(String arg0)
  • Example : driver.get("http://www.google.com");
Use of get Method
In selenium webdriver, we can open browser with given url string using get method. Browser can be anyone like Mozilla Firefox, Google Chrome, Internet Explorer, Opera, Safari, etc.

Below given example will show you how to open firefox browser with "https://www.google.co.in" url. You have to set geckodriver path before opening firefox browser. Read More on how to set geckodriver path.

Example Of get Method
package Methods;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class OpenMethod {
 
 public static void main(String[] args){
 
 //Set geckodriver path for FirefoxDriver.
 System.setProperty("webdriver.gecko.driver", "E:\\geckodriver.exe");
 //create object of FirefoxDriver.
 WebDriver driver = new FirefoxDriver();
  //Call get method to open browser.
  driver.get("https://www.google.co.in"); 
 }
}

OutPut : It will load Firefox browser and then open https://www.google.co.in url in browser.

Same way you can use get method to open Google chrome, Internet Explorer, Opera or any other webdriver supported browser.

No comments:

Post a Comment