LinkedIn Free Week of Learning

LinkedIn offers free week of learning from October 24-30. This means all the courses available in LinkedIn are 100% free. You can pick up any course and learn it end to end for free in this one week. It can be anything from a basic Hello World program to Cloud Computing, Mobile Development, AI, Machine Learning, Big Data etc. If you want to become good at your leadership/managerial skills you got those soft skills development courses as well.

As a QA Engineer, this is the right time to go and grab some of the interesting courses.

Here are some of the QA courses for anyone who want to pursue a career in QA.

Foundations Of Programming: Software Quality Assurance – In this course, the author demonstrates the different kinds of software testing (from black box to white box) and how to fit each one into your development cycle. Find out how to test and report issues, and how to use a tracking system to manage the process and the results. How automating some of the testing can make the QA process more efficient and objective.

Insights On Software Quality Engineering – In this course,  the author share his personal insights and cautionary tales and discusses how to get started in QA, how it fits in at companies small and large, and how it has changed since the rise of agile workflows.

Java Essential Training

Up And Running With Java

The above courses covers basics of Java right from Hello World to required OOPS concepts that we will be using in our automation programs.

Using JUnit For Testing In Java – JUnit is an open-source testing tool specialized for Java, and it should be part of every QA Automation Engineer toolbox. Learn how to integrate JUnit with popular tools and IDEs (Eclipse, NetBeans, IntelliJ, and Maven), and conduct a variety of tests, including exception handling and parameterized tests. If you are going to learn Selenium, its good to learn any of the unit testing frameworks like Junit/TestNG.

Mastering Selenium Testing Tools – Here comes the most widely used tool in our test automation. This course is all about demystifying the Selenium suite. Learn to verify web applications, control browsers with code, and scale up the testing environment by distributing the execution of web applications on different browsers running on different operating systems. It starts with the Selenium IDE, and locating techniques like name, id, xPath, or CSS. This also covers Behavior Driver Development along with a complete automation project.

Learning Python Web Penetration Testing – This course starts off by providing an overview of the web application penetration testing process and the tools the professionals use to perform these tests and then interact with web applications using Python, HTTP, and the Requests library. Also it shows how to use the tools against a vulnerable web application created specifically for this course with practical examples.

Following is the learning path, If you want to Become a Leader.

Following is the learning path, f you want Become a Manager.

I just have mentioned very few courses related to QA Career Paths. Still there are plenty of courses available for free. But its free just for a week.

#AlwaysBeLearning

Selenium 3.0 Officially Out Now

Yes. This is one of the major and stable release in the recent times since 2.0 got released around 5 years back.

What’s new we can expect: For users who are using WebDriver API’s this is gonna be just a drop in effortless replacement. But those who are using Selenium Grid may have to go through some minimal configuration changes.

In this version, they have removed the original Selenium Core implementation and replaced it with one backed by WebDriver. For people who are still using Selenium RC should have to undergo some maintenance because of this. This is the right time to migrate the code to WebDriver API’s.

Right from Selenium 3.0, all the major browser vendors are responsible for shipping their own implementation of WebDrivers for their browsers.

Starting with Safari-10, Apple started providing native support for WebDriver API’s. More details here – WebDriver Support in Safari 10

Google already started providing support for WebDriver API’s for Google Chrome using their ChromeDriver.

Even Microsoft when they came up with a new browser “EDGE” for Windows-10, they also came out with support for the WebDriver API’s – Microsoft WebDriver

Mozilla is doing major changes in the internals of Firefox browser to make it more stable and secure. So if you are using Firefox for your testing, you’ll need to use the GeckoDriver, which is an executable similar to the ChromeDriver. But Gecko is still in Alpha and you may have to face lot of issues with your automation w.r.t. Firefox.

The W3C specification for browser automation, based on Open Source WebDriver is still In-Progress and this is gonna reach “recommendation” status.

What you are waiting for? Just go and download the latest from Seleniumhq Downloads

Selenium 2016 Conference

Sometimes back I got an opportunity to attend the Selenium 2016 Conference in Bangalore India and it was a very good exposure for me to learn how people are doing things difference than me.

I thought of writing a detailed blog post for each and every session. But due to my busy schedule, I was not able to focus on my writing for the last few months.

So I am going to summarize some of the key take away sessions in this blog posts. The Slides and Videos are already there in the Conf Engine Site – Selenium 2016 Conference Slides & Videos.

The first and most favorite session was The Interviewer, Interviewee and vice-versa by Robin. Even-though he related this session with Selenium interviews, I can say each and everyone in our industry should watch this video once. Its not technical. But its funny and I enjoyed a lot. I highly recommend this for the interviewers to “What not to ask” in an interview.

The next one that I liked most is Automating the Responsive Web Design TestingIf you are developing a site/app and open to public, chances are there that our end users will access our app in a desktop, mobile or in a tablet. This session has some good amount of technical information related to Galen which helps us in automating testing for look and feel for our responsive websites.

Functional & Security Testing session is another interesting one which I already have tried out in one of my blog post Security Test Automation using Selenium and ZAP

Testing as a Container is a technical session which talks about leveraging the container technologies to solve the challenges of growing testing infrastructure and continuous delivery. We can learn how Docker works and why its important to our testing.

Automated Visual Testing – This session talks about modern comparison engines and visual testing tools like Applitools. It also talks about how we can use these image comparison tools to automation our baseline tests.

Test Data – Food for your Framework – This one talks about test data management. There is a myth in our automation that if there is a test data, it needs to be externalized in a config/excel or some other file other than source code. But this talk will break those beliefs.

Practical Tips & Tricks for Selenium by Dave the author of http://elementalselenium.com/ and https://seleniumguidebook.com/ gives us lot of advanced tips and tricks that will be helpful for our day to day automation activities.

Advanced Appium by Dan talks about Appium, the leading Mobile Test Automation Tool. This one is more technical and if you are learning any mobile test automation tool, at some point you have to go through this video.

Still there are plenty of interesting talks and Lightning Talks. You can go through all of these here – Selenium 2016 Conference Slides & Videos.

This is the Selenium 2016 Youtube Video Playlist where you can see all the videos.

Overall – Its lots & lots of key takeaways and learning from this conference. Eagerly looking forward to implement some of these ideas in my automation projects.

JMeter SFTP Request

In my previous post, we have seen how to utilize an external groovy script to make some FTP Requests.

Now there is slight change in the requirement. FTP got changed to SFTP, which means it’s more secure.

We can’t use our FTP Samplers to create a SFTP request to authenticate using SSH.

Originally I built the SSH FTP Sampler using the instructions in HOW TO BUILD SSH SFTP SAMPLER FOR JMETER? (BY IMPLEMENTS TESTBEAN)

We have to check out the source code from https://github.com/yciabaud/jmeter-ssh-sampler and then generating the target by building it using maven.

Also we need Jsch. JSch is a java implementation of SSH. This allows us to connect to an FTP server for file transfer. http://sourceforge.net/projects/jsch/files/jsch.jar/0.1.53/jsch-0.1.53.jar/download

But just to make this process simpler, I checked-in the two jar files required for creating SSH FTP request here – https://github.com/linkeshkanna/Jmeter.SSH.FTP.Request

This contains two jar files.

  1. jmeter-ssh-sampler-1.0.2-SNAPSHOT.jar
  2. jsch-0.1.53.jar

To install this in Jmeter,

  1. Copy the jmeter-ssh-sampler-1.0.2-SNAPSHOT.jar to the “Jmeter/Lib/ext” directory.
  2. Copy the “jsch-0.1.53.jar” to the “Jmeter/Lib” directory
  3. Restart Jmeter.

I have also added a sample test to list of the directory contents in a Public SFTP Server – https://github.com/linkeshkanna/Jmeter.SSH.FTP.Request/blob/master/SSH-FTP.jmx

Open this JMX file in your JMeter and run it to see this in action.

Jmeter Groovy Scripting – Call External Scripts

In my previous post, Jmeter BeanShell Scripting – Call External Scripts we have discussed how to user Jmeter Bean Shell script to call external .bsh scripts.

Now in this post, we are going to see how to do the same functionality with JSR 223 sampler + Groovy scripting.

It’s always recommended to use JSR 223 Sampler instead of Bean shell Sampler. I recently got a nice comparison between these two in this post – BeanShell Vs JSR223 Sampler

The JSR223 test elements have a compilation feature that can significantly increase performance.

To get benefit from this feature, Use external .groovy Script files instead of in lining them. This will make Jmeter compile them if this feature is available on Script Engine and cache them.

To get additional benefits from Caching and compilation, language engine used for scripting must implement JSR223 compilable interface.

Groovy is one of the JSR223 compilable interface. But Java, Bean Shell and Java script are not.

Since JMeter 2.8, JSR223 Test Elements using external Script file are now pre compiled and this enables great performance enhancements.

So we are going to use JSR223 test elements with external Groovy script files.

Pre Requisites:

Groovy isn’t shipped with Jmeter. So it needs to be downloaded separately.  To get started:

  1. Download latest groovy binary bundle from http://groovy-lang.org/download.html
  2. Copy all the Jar files under “groovy-{versionNumber}\lib” and paste it into “Jmeter/lib/ext” folder of your Jmeter installation directory.
  3. Restart Jmeter.

Scenario:

Now we are going to do the same scenario as in the previous post. But instead of http requests, I am gonna do FTP Requests. In short following is the scenario.

I have to do upload some flat files to a FTP server through FTP requests and the flat files are available on a sub directory where my test plan file – .JMX file exists. So I have to parse the list of available files and have to pass the file names as input to my FTP Requests.

I am going to create two external groovy script files for this scenario.

One is for listing out the files under sub directory and putting the absolute path of the Flat files it into a Jmeter variable.

Another script is for extracting the file names alone from the absolute path Jmeter variables.

Following is the “FlatFilePathProcessor.groovy” script file content and I have saved this file where our test plan file exists.


import org.apache.commons.io.FilenameUtils;
import org.apache.jmeter.services.FileServer;

String subDirectory = args[0];
String testPlanFile = FileServer.getFileServer().getBaseDir().replace('\\', '/');
//String testPlanFileDir = FilenameUtils.getFullPathNoEndSeparator(testPlanFile).replace('\\', '/');

vars.put("testPlanFileDir", testPlanFile);

File folder = new File(testPlanFile + "/" + subDirectory + "/");
File[] listOfFiles = folder.listFiles();
int counter = 1;
for (File file : listOfFiles) {
if (file.isFile()) {
vars.put(subDirectory + "_" + counter, testPlanFile + "/" + subDirectory + "/" + file.getName());
vars.put("FileNames" + "_" + counter, file.getName());
}
counter++;
}


Following is the “ExtractFileName.groovy” script file content and I have also saved this file where our test plan file exists.


String fullPath = vars.get("FlatFiles");
int index = fullPath.lastIndexOf("/");
String fileName = fullPath.substring(index + 1);
vars.put("FileName", fileName);

Following is the project structure that we are going to create.

1

Create a test plan and then create a thread group below that.

First we are going to add JSR 223 sampler in our thread group. – the job of this sampler is to call the FlatFilePathProcessor.groovy file with sub directory name as a parameter. So the request will list out the flat files under sub directory and putting the absolute path of each and every flat file it into a Jmeter variable. Following is the request.

2

Next we are going to create a ForEach Controller, which will loop through the FTP for each flat file variable created in the above step. Following is our controller.

3

Now we are going to create JSR 223 Pre-processor. The job of this test element is to call ExtractFileName.groovy to extract the file name from the absolute path. Because for FTP request we need both the file name as well as the absolute file path.

Also one more thing I have noticed is, in FlatFilePathProcessor.groovy itself, we have created two variables one contains the absolute path and another for the file name. But now we are under the ForEach controller, which will process/loop through only one variable. I have not seen any reference where the ForEach controller loop through multiple variables. Following is the request.

4

Here comes the actual FTP Request, with simple response code assertion. We have used two variables here – one for filename that we got from preprocessor [ExtractFileName.groovy] and another for the absolute file path of the flat file which we are going to upload, that we got from sampler [ExtractFileName.groovy].

5

Add debug sampler and your favorite listener to see this in action.

The source code of the sample program is here – https://github.com/linkeshkanna/Jmeter.External.Groovy.Scripts

Jmeter BeanShell Scripting – Call External Scripts

Recently I come across a requirement to use Beanshell Scripting in Jmeter. So following is my requirement.

  1. Create 2 thread groups for 2 Http Requests to make API Calls and in that http request, my Post body should be iterated for around 9000 flat files in two different directories. Following is the Project Structure I have.1
  1. For HttpRequest1 under ThreadGroup1 I have to iterate for all the text files in ‘DirectoryOne’
  2. For HttpRequest2 under ThreadGroup2 I have to iterate for all the text files in ‘DirectoryTwo’

Challenges:

  1. Need to use absolute Path for pointing to the directory where my files exist – Not a better solution, when running from the CI build, this absolute path will vary.
  2. Need to use another CSV file(s) to configure the list of filenames available under ‘DirectoryOne’ and ‘DirectoryTwo’ – Not a feasible solution. If there is any new addition of new files under any directory, I have to update my CSV file to include the new file names as well.
  3. Read the text file content and pass it as a post body request.

Let’s start solving this issue.

I started exploring the bean shell sampler in Jmeter. I have created a bean shell script to process the flat files under ‘DirectoryOne’. Following is the bean shell script


import org.apache.jmeter.gui.GuiPackage;

import org.apache.commons.io.FilenameUtils;



String testPlanFile = GuiPackage.getInstance().getTestPlanFile();

String testPlanFileDir = FilenameUtils.getFullPathNoEndSeparator(testPlanFile).replace('\\', '/');



vars.put("testPlanFileDir", testPlanFileDir);



File folder = new File(testPlanFileDir + "/" + "DirectoryOne" + "/");

File[] listOfFiles = folder.listFiles();

int counter = 1;

for (File file : listOfFiles) {

if (file.isFile()) {

vars.put("DirectoryOne" + "_" + counter, testPlanFileDir + "/" + "DirectoryOne" + "/" + file.getName());

 }

counter++;

}

2

If you look into the above issue, I have pointed to the root directory [whatever it may be] where my test plan file exist and then I am appending my sub directory name to it.

But for ThreadGroup2, I have to copy paste the same bean shell sampler with same script except for ‘DirectoryTwo’ instead of ‘DirectoryOne’. So I thought of reusing the same bean shell script for all the thread groups. The only option is to externalize it.

Now I have created a file called “FilePathProcessor.bsh” inside the same directory where my test plan file exists. One interesting thing that I have noticed in the bean shell sampler was it will even run the external .bsh scripts with arguments passed from Jmeter.

Again I have to use a relative path to locate this external .bsh file. Following is the small snippet that you can use to point your bean shell Sampler – “Script File Text Box”.


${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}FilePathProcessor.bsh

This means, no need for providing the absolute path to locate the external bean shell script. The above code will point to the base directory where our test plan/.JMX file exists.

Now we have to pass the sub directory names as an argument in the “Parameters (-> String Parameters and String []bsh.args)” text box.

For first ThreadGroup, I have passed it as ‘DirectoryOne’.

For Second ThreadGroup, I have passed it as ‘DirectoryTwo’.

So my updated external bean shell script will look like,


import org.apache.jmeter.gui.GuiPackage;

import org.apache.commons.io.FilenameUtils;



String subDirectory = bsh.args[0];

String testPlanFile = GuiPackage.getInstance().getTestPlanFile();

String testPlanFileDir = FilenameUtils.getFullPathNoEndSeparator(testPlanFile).replace('\\', '/');



vars.put("testPlanFileDir", testPlanFileDir);



File folder = new File(testPlanFileDir + "/" + subDirectory + "/");

File[] listOfFiles = folder.listFiles();

int counter = 1;

for (File file : listOfFiles) {

if (file.isFile()) {

vars.put(subDirectory + "_" + counter, testPlanFileDir + "/" + subDirectory + "/" + file.getName());

}

counter++;

}

2.1

So my final project structure will look like,

3

FilePathProcessor – the Bean Shell Sampler. This will produce JmeterVariables for each file located in the sub directory. For example, when iterating over the files in ‘DirectoryOne’ and if it has two files exists, this will produce two Jmeter Variables with Prefix ‘DirecotryOne’. You can see this in action using Jmeter Debug Sampler.

DirectoryOne_1 = “D:\DirectoryOne\Test1.txt”

DirectoryOne_2 = “D:\DirectoryOne\Test2.txt”.

I have created ‘ForeEach Controller’ to parse these Jmeter Variables.

4

The “Output Variable Name” in the ‘ForEach Controller’ will contain the absolute path of the text files. Now to parse the text inside a text file, we can simply use in-built Jmeter functions. Go-to Body Data of HttpRequest and write ${__FileToString(${DirectoryOneFileNames})}

The _FileToString in built Jmeter function will return the file content of a given flat file.

5

So that’s it. Now we have solved all the possible challenges in-front of us. If you want to have complete information about this project, you can simply have a look at this sample script here.

https://github.com/linkeshkanna/Jmeter.External.BeanShell.Scripts

Virtualization using Vagrant for Selenium Tests

Say goodbye to “works on my machine” bugs.

Nobody likes to release software on a Friday. What if something breaks over the weekend? There’s nothing like debugging an issue in production when you’re doing some day drinking at a BBQ.

But you have nothing to worry about, right? I mean, you tested the application and it worked on *your* machine. Too bad that’s never good enough. Have fun working this weekend.

If only you had automated tests for your application (across all of the browsers and all the platforms you cared about). Then you could rest easy this weekend and enjoy the festivities.

Creating a robust and scalable execution environment for automation tests is a very essential phase. In automated tests for web, we actually need to cover different browsers and platforms.

In this documentation, we are going to see how to run our selenium tests in a Linux box using vagrant.

Basically I have a selenium test that works fine when running in different browsers in my Windows host machine. But I want to make sure that it is running fine on the browsers in a Linux box too. Instead of creating an actual VM and running my tests, I am simply going to create a light weight portable Linux box and I am going to run my selenium tests from my windows host machine.

Also every time that you want to run your tests in your local machine, it opens the browser on top of the other windows, preventing you from doing something else. Unless you use Phantomjs or HTMLUnitDriver, it is not possible to run Chrome or Firefox hidden, without disturbing you on your work. Now using Vagrant and VirtualBox, you only need to start the VM, and all your tests will be run into the VM. You can continue developing in the meanwhile!

WHY VAGRANT?

Vagrant provides us easy to configure, reproducible, and portable work environments. Vagrant stands on top of VirtualBox, VMware and some other service providers. If you’re a developer, Vagrant will isolate dependencies and their configuration within a single disposable, consistent environment. If you’re a tester, Vagrant will help you to create light weight Virtual environments to run your tests against all the possible OS + Browser combinations.

Prerequisites:

  1. Download and install Oracle VM Virtualbox – https://www.virtualbox.org/wiki/Downloads
  2. Download and install Vagrant – http://www.vagrantup.com/downloads

From command line, type vagrant –v and make sure that you get the version number that you installed. Vagrant 1.7.21

Vagrant Boxes:

Boxes are the package format for Vagrant environments. A box can be used by anyone on any platform that Vagrant supports to bring up an identical working environment. The easiest way to use a box is to add a box from the publicly available catalog of Vagrant boxes for VirtualBox. We can also add and share our own customized boxes on this website.

I am going to use this box chef/ubuntu-14.04 – a standard Ubuntu 14.04 x64 base install.

Getting Started:

  1. Create a workspace directory to store the vagrant configuration file and shell scripts.

I have created “D:\Automation\Vagrant\Demo”

  1. From Command line go to your workspace and type vagrant init chef/ubuntu-14.04

2

  1. Make sure that the vagrant file is created in “D:\Automation\Vagrant\Demo”
  2. Run the command vagrant up

3If you are running this for first time, it may take some considerable amount of time to download the virtual box image and will put it under C:\Users\<username> \VirtualBox VMs\Demo_default_*

  1. Now the Ubuntu base image VM is up and running. Run the Command vagrant halt. This will power off the VM. Because we need to provision this VM with selenium related libraries, browsers and some utilities to run our selenium tests.
  2. Update the vagrant file in “D:\Automation\Vagrant\Demo” with the following content. Basically the default generated vagrant file has some lot of optional behaviors which are commented by default and you may enable it you need. But we require only the following content in a vagrant file.

 

Vagrant.configure(2) do |config|
   config.vm.box = "chef/ubuntu-14.04"
   config.vm.provision :shell, :path =&gt; "Provisioner.sh"
   config.vm.network :forwarded_port, guest:4444, host:4444
end

Basically what we are trying to do above is enabling port forwarding in the VM. Selenium server will use the 4444 port by default and we are forwarding that port from VM to host machine.

Also we are going to provision this VM using the “Provisioner.sh” shell script. Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine, as part of the vagrant up process. This is useful since boxes typically aren’t built perfectly for your use case. Of course, if you want to just use vagrant ssh and install the software by hand, that works. But by using the provisioning systems built-in to Vagrant, it automates the process so that it is repeatable. Most importantly, it requires no human interaction, so you can vagrant destroy and vagrant up and have a fully ready-to-go work environment with a single command.

Vagrant gives you multiple options for provisioning the machine, from simple shell scripts to more complex, industry-standard configuration management systems. If you’ve never used a configuration management system before, it is recommended you start with basic shell scripts for provisioning.

So to run a selenium test in a new plain OS, we need following things.

  • JDK/JRE – To run the selenium server.
  • Google chrome browser
  • ChromeDriver
  • Some utilities like ‘Unzip’ to extract the chromedriver zip file.
  • Selenium Standalone Server
  • Xvfbor X virtual framebuffer – To run tests in headless mode.

Xvfb is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output. So actually when we run our tests in a VM box, we won’t be able to see any browser popping up. It means no GUI interactions are possible. So I am going to install all the above packages along with the dependencies using Provisioner.sh

  1. Create Provisioner.sh in the “D:\Automation\Vagrant\Demo” with the following content.

#!/usr/bin/env bash

# Set start time so we know how long the bootstrap takes

T="$(date +%s)"

#echo 'Updating'

sudo apt-get -y update

echo 'Installing Zip/Unzip'

sudo apt-get -y install zip unzip

echo 'Installing Google Chrome'

sudo apt-get -y install google-chrome-stable

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i google-chrome-stable_current_amd64.deb

sudo apt-get -y install -f

echo 'Installing Google XVFB'

sudo apt-get -y install xvfb

sudo apt-get -y install -f

echo 'Installing JRE'

sudo apt-get -y install default-jdk

sudo apt-get -y install -f

echo 'Downloading and Moving the ChromeDriver/Selenium Server to /usr/local/bin'

cd /tmp

wget "http://chromedriver.storage.googleapis.com/2.8/chromedriver_linux64.zip"

wget "https://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar"

unzip chromedriver_linux64.zip

mv chromedriver /usr/local/bin

mv selenium-server-standalone-2.35.0.jar /usr/local/bin

export DISPLAY=:10

cd /vagrant

echo "Starting Xvfb ..."

Xvfb :10 -screen 0 1366x768x24 -ac &

echo "Starting Google Chrome ..."

google-chrome --remote-debugging-port=9222 &

echo "Starting Selenium ..."

cd /usr/local/bin

java -jar selenium-server-standalone-2.35.0.jar

# Print how long the bootstrap script took to run

T="$(($(date +%s)-T))"

echo "Time bootstrap took: ${T} seconds"

  1. Run vagrant up –provision this will start the VM and then install the list of packages that we have added in the sh and also it will start the selenium server in 4444 port.

4

You can see this by navigating to http://localhost:4444/wd/hub/static/resource/hub.html from your windows host machine [As we have port forwarded].

Now run the following selenium test from any of your favorite IDE.

package test;

import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class HeadlessSession {	  
	  public static void main(String args[]) throws InterruptedException, Exception {	  
		  HeadlessSession.HeadlessSessionId();
	  }
	  
	  public static void HeadlessSessionId() throws Exception {
               DesiredCapabilities capabilities = new DesiredCapabilities();
	       capabilities.setBrowserName("chrome");
	       WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);	  
		  try {				
			    String baseUrl = "http://www.google.com";
			    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
			    driver.get(baseUrl);
			    System.out.println("Title : " + driver.getTitle());
			    String browserName = capabilities.getBrowserName().toLowerCase();
			    System.out.println("Browser : " + browserName);
		  } catch (Exception e) {
			  System.out.println(e.getMessage());
		  }
		  finally {
		    driver.close();
		    driver.quit();
		  }
	  }
}

That’s it. Now you have successfully ran your tests in Chrome browser in a Linux box from your windows host machine.

Useful Vagrant Commands:

Command Action
vagrant up Power on the VM
vagrant halt Power off the VM
vagrant reload Restart
vagrant suspend Saving the VM state and sleep
vagrant resume Resuming the suspended VM
vagrant provision Provision the VM by running the Provisioner.sh or any other shell script mentioned in the vagrant file.
vagrant up –provision Power on with provision
vagrant reload –provision Restart with provision

Pros:

  1. Easy to setup and maintain.
  2. It’s free.
  3. Able to clone the production/staging environment for our test execution.
  4. Light weight and portable.
  5. Support to provisioning scripts like Shell, Chef, and Puppet.
  6. Simple command line based workflow.
  7. Goodbye to ‘Works on my machine’ bugs.
  8. For selenium, you can able to run headless tests on your favorite browser.
  9. Create and destroy the VMs as needed.
  10. It works on all major platforms.
  11. We can also use Selenium Grid along with vagrant to run tests parallely across different VM’s.

Cons:

  1. Base boxes for your choice of operating system might not be readily available.
  2. Little bit of time consuming to make vagrant VM up and running.
  3. Taking lot of time when provisioning the VM box. To avoid this, create your own base box by installing all the required dependencies by manually SSH into it and then use provisioning script only for starting the Selenium Server.
  4. Light weight. But looks fatty when considering the alternatives like Docker.
  5. It requires you to have a hard drive file that can be huge and it takes a lot of RAM.