Tuesday, March 29, 2016

linux java shows older version after upgrade

While working with Linux today I stumbled upon a weird problem, even after upgrading java to 1.8 it was showing 1.7 only.

And when I tried to install it again, it showed me following message.
sudo yum install java-1.8.0-openjdk.x86_64

Package 1:java-1.8.0-openjdk- already installed and latest version

Nothing to do
Following command help me to figure out what's going wrong. 

Following command will show you all the java versions currently installed on your system, it will also show you which one is currently active.  If you need to change just provide the number and that would be activated. 

sudo update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
 + 1           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
*  2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number:

Friday, December 18, 2015

JVM Cucumber Hooks Part 1

As the name itself suggests hooks are used to hook any feature or scenario. In a simpler terms you can create a function and then hook that into any feature or scenario.

There are two types of hooks you can create.  Please not there ain't such categories, I have just divided them into following categories for better understanding.
  • Generic Hooks:  Hooks that executes before or after each and every scenario.
  • Specific Hooks: Hooks that executes before or after every specific(mentioned) scenario or feature. 

Now let's see how to implement this, for this I am going to use the same example I used in the last blog post. if you haven't read that yet, please visit it here. 

Generic Hooks

if you will check the code of the previous post, we were creating the driver object, in the class file as we had only one test case(scenario).  if we have multiple scenarios and we want to open new browser before each and every scenario and want to close after each and every scenario we can utilize the hooks.

In the following example, I am going to create a hook (setUp method) that will be called before each and every scenario. this method will open a firefox browser and will navigate to site home page. I will also create an another hook (tearDown method) which will be called after each and every scenario. This method will close the browser after each and every scenario.

public class Hooks extends WebDriverManager{

    public void setUp(){
        driver = new FirefoxDriver();
        wait = new WebDriverWait(driver, 30);

    public void tearDown(){

public class WebDriverManager {
    public static WebDriver driver;
    public static WebDriverWait wait;

public class HomePage extends WebDriverManager{
    @When("^I search \"(.*?)\"$")
    public void i_search(String arg1) throws Throwable {
        WebElement search_box = driver.findElement(By.id("searchInput"));

    @Then("^I should get \"(.*?)\" on page$")
    public void i_should_get_on_page(String arg1) throws Throwable {

Feature: Verify WikiPedia Search

  @Regression @Functional
  Scenario: Verify Wikipdia for indirect posts-BDD
  When I search "BDD"
  Then I should get "Behavior-driven development" on page

  Scenario: Verify Wikipdia for indirect posts-TDD
  When I search "TDD"
  Then I should get "Test-driven development" on page