Selenium Webdriver Instantiation in Selenium(3.7.x)

Capture
In latest selenium 3.7.x version, most of the drivers (Chrome, Firefox, IE, Safari) are deprecated; in the next release of selenium will remove those driver instantiation logic. Following are the new way of driver instantiation in selenium 3.7.x:
For Internet Explorer:
WebDriver driver;
System.setProperty(“webdriver.ie.driver”, <path to IEDriverServer>);
InternetExplorerDriverService ieservice= new InternetExplorerDriverService.Builder().build();
driver = new InternetExplorerDriver(ieservice);
For Chrome:
WebDriver driver;
System.setProperty(“webdriver.chrome.driver”, <path to chromedriver>);
ChromeDriverService chromeservice= new ChromeDriverService.Builder().build();
driver = new ChromeDriver(chromeservice);
For Firefox:
WebDriver driver;
System.setProperty(“webdriver.gecko.driver”, <path to geckodriver>);
GeckoDriverService geckoservice= new GeckoDriverService.Builder().build();
driver = new FirefoxDriver(geckoservice);
For Safari (on MAC)
WebDriver driver;
SafariOptions options = new SafariOptions();
options.useCleanSession(true);
driver = new SafariDriver(options);
Happy Automation Testing !
Make it perfect !

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: