Different Driver Services in Selenium and Appium


     As we know that the importance of Automation is increasing day-by-day. And also most of them are looking for open source tools like Selenium and Appium. In 2017, there are some modification happened in Driver instantiation for Selenium Drivers and Appium Drivers. They are commonly using DriverServices to build and start the services for different automation sessions. Here I would like to explain important Driver Services from Selenium and Appium.

For Internet Explorer:
WebDriver driver;
InternetExplorerDriverService service = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File(<path to IEdriver executable>)).usingAnyFeePort().withLogFile(new File(System.getProperty(“userdir”)+”\\Logs\\Browser_logs\\InterntExplorer_”+getCurrentDateAndTime()+”.txt”)).withLogLevel(InternetExploreDriverLogLevel.DEBUG).build();
driver = new InternetExplorerDriver(service);

For Chrome:

WebDriver driver;
ChromeDriverService chromeservices = new ChromeDriverService.Builder().usingDriverExecutable(new File(<path to chromedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“userdir”)+”\\Logs\\Browser_logs\\Chrome_”+ getCurrentDateAndTime() + “.txt”)).withVerbose(true).build();
driver = new ChromeDriver(chromeservices);

For Firefox:

WebDriver driver;
FirefoxOptions options = new FirefoxOptions();
GeckoDriverService geckodriverservice = new GeckoDriverService.Builder().usingDriverExecutable(new File(<path to geckodriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”) + “\\Logs\\Browser_logs\\Firefox”+getCurrentDateAndTime() + “.txt”)).build();
driver = new FirefoxDriver(geckodriverservice, options);

For Edge:

WebDriver driver;
EdgeDriverService edgeservice = new EdgeDriverService.Builder().usingDriverExecutable(new File(<path to edgedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”)+”\\Logs\\Browser_logs\\Edge_”+ getCurrentDateAndTime() + “.txt”)).build();
driver = new EdgeDriver(edgeservice);

For PhantomJS:

WebDriver driver;
Capabilities caps = new DesiredCapabilities();
((DesiredCapabilities) caps).setJavascriptEnabled(true);
((DesiredCapabilities) caps).setCapability(“takesScreenshot”, true);
PhantomJSDriverService phantomjsservice = new PhantomJSDriverService.Builder().usingPhantomJSExecutable(new File(<path to phantomjs executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”)+”\\Logs\\Browser_logs\\PhantomJS_”+ getCurrentDateAndTime() + “.txt”)).build();
driver = new PhantomJSDriver(phantomjsservice, caps);

For Electron Rendered Applications:

WebDriver driver;
ChromeOptions options = new ChromeOptions();
ChromeDriverService chromeservices = new ChromeDriverService.Builder().usingDriverExecutable(new File(< path to chromedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”) +”\\Logs\\Browser_logs\\Electron_”+ getCurrentDateAndTime() + “.txt”)).withVerbose(true).build();
driver = new ChromeDriver(chromeservices, options);

For Safari:

WebDriver driver;
SafariOptions options = new SafariOptions();
driver = new SafariDriver(options);

For Appium:

WebDriver driver;
AppiumDriverLocalService driverService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withAppiumJS(new File()).usingDriverExecutable(new File()).withIPAddress(“″).usingPort(4723).withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,”4724″).withArgument(AndroidServerFlag.CHROME_DRIVER_PORT,”4725”).withLogFile(new File(new File( System.getProperty(“user.dir”) +”\\Appium_logs\\appiumLogs_” + getCurrentDateAndTime() + “.txt”))

For Winium (Windows Desktop Applications):

WebDriver driver;
DesktopOptions options = new DesktopOptions();
options.setApplicationPath(<path to windowsApplication>);
WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(new File(< path to winiumDriver executable>)).usingPort(9999) .withLogFile(new File(System.getProperty(“user.dir”) + “\\Logs\\Windows_logs\\Win_” + getCurrentDateAndTime() + “.txt”)) .withVerbose(false).withSilent(false).buildDesktopService();
driver = new WiniumDriver(service, options);

Try to use above mentioned Driver Services in your automation scripts.

make it perfect !

Selenium Webdriver Instantiation in Selenium(3.7.x)

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();
driver = new SafariDriver(options);
Happy Automation Testing !
Make it perfect !


Selenium – Sikuli


Automate anything you see using Sikuli (an interesting GUI automation tool). As said Sikuli automates anything you see on-screen using the image recognition method to identify GUI elements on the screen.

Most of the automation testing tools will not support flash object automation (E.g. Selenium). Sikuli provides extensive support to automate flash objects. And also Sikuli provides support to automate desktop applications.

Selenium-Sikuli combination provides more support for the automation engineers. Most of the time in automation for web application, we may face to identify the elements from the web UI or the locators values are getting wrong. In such situation Sikuli comes in picture, Sikuli allows to automate GUI interaction by using images of elements instead of using the xpath, id, linktext, classes etc.,

Important steps to proceed

  1. Create a Maven project in Eclipse.
  2. Add following dependencies in pom.xml file:
    1. selenium-server
    2. selenium-java
    3. sikulixapi
    4. testng
  3. Create TestNG classes.
  4. Create WebDriver object to start driver session and load website.
  5. Create a folder inside src/main/resources and store the images of web elements inside that folder.
  6. Add the sikuli scripts to perform operations on the elements (like click, type, wait, doubleClick).
  7. Create a testng.xml file for the created TestNG class and execute testng.xml.
  8. Observe the results on executions.

Below is the sample Selenium-Sikuli Maven project structure:


Common Sikuli Actions

Create an object for Screen class, say Screen s = new Screen(); and perform various actions:

  1. click :  s.click(<path to image>); – helps to click on web element using its image.
  2. rightClick : s.rightClick(<path to image>); – helps to right-click on web element using its image.
  3. doubleClick : s.doubleClick(<path to image>); – helps to double-click on web element that displaying in the view.
  4. find : s.find(<path to image>); –  helps to locate a web element using the image of particular web objects.
  5. exists : s.exists(<path to image>); – helps to check the web element is present on the view.
  6. type : s.type(<path to image>, <input value to edit-box>); – helps to enter value to an input field.
  7. hover : s.hover(<path to image>); – helps to mouse hover a web element in the web page.
  8. wait : s.wait(<path to image>); – helps to wait for a web element on the page until it get displayed. There another method for wait is with timeout value, it looks like s.wait(<path to image>, <timeout in seconds>);
  9. dragDrop : s.dragDrop(<source image path>, <target image path>); – helps to drag an object(source image object) from one location and drop that object over other object (target image object) at target location.

Click here to get sample Selenium – Sikuli POC project and explore more. If you have any difficulty to get the POC project, please feel free to comment here.

How To Press Keyboard Keys in Selenium?

The Problem

On occasion you’ll come across functionality that requires the use of keyboard key presses in your tests. Perhaps you’ll need to tab to traverse from one portion of the page to another, back out of some kind of menu or overlay with the escape key, or even submit a form with Enter.

But how do you do it and where do you start?

A Solution

You can easily issue a key press by using the send_keys command.


Alternatively, you can also issue a key press without finding the element first,

Actions builder = new Actions(driver);

SafariDriver, Safari 10 for desktop web automation

About SafariDriver

The SafariDriver is implemented as a Safari browser extension. The driver inverts the traditional client/server relationship and communicates with the WebDriver client using WebSockets.

Apple’s decision to drop Safari on Windows

The SafariDriver requires Safari 5.1+. Consequently, SafariDriver on Windows will most likely not work on newer versions of Safari and/or Windows because of Apple’s decision to drop Safari on Windows. Apple apparently kills Windows PC support in Safari 6.0

Safari 10 for desktop web automation

Need to do following set up before starting the execution:

  1. Ensure that the Develop menu is available. It can be turned on by opening Safari preferences (Safari > Preferences in the menu bar), going to the Advanced tab, and ensuring that the Show Develop menu in menu bar checkbox is checked.
  2. Enable Remote Automation in the Develop menu. This is toggled via Develop > Allow Remote Automation in the menu bar.

NOTE: Sometime you may face Unable to start the server: another safaridriver is already running. You can resolve this problem by running following command via terminal,

> launchctl list | grep webdriverd

> sudo kill xxxx

where xxxx is the process id of the webdriverd process. Which it looks like you may already have tried.

ServerSocket socket;

try {

socket = new ServerSocket(0);


port = socket.getLocalPort();


} catch (IOException e) {


SafariOptions options = new SafariOptions();



driver = new SafariDriver(options);