Replacing FF driver with Chrome in JBehave’s tutorial project

Hi All,

Recently I’ve started playing with JBehave or rather with their interesting extension JBehave-web

JBehave-Web is a collection of extension for JBehave that extend its capabilities in ways related to HTTP and the web.

As a starting point I tried running an example project available here: https://github.com/jbehave/jbehave-tutorial.
After getting bored with running all the tests in FF, I’ve decided to replace it with Chrome. Below is the short tut. describing how to do that 🙂

Steps to get you there:

  1. Download chrome driver
  2. Change the webDriver to a PropertyWebDriverProvider
  3. Set System Properties

Step 1)
Download chrome driver that suits your needs: http://code.google.com/p/chromedriver/downloads/list
Extract it wherever you want.

Step 2)
Change the webDriver from FirefoxWebDriverProvider to a PropertyWebDriverProvider that allows running your tests with Google Chrome.
Edit etsy-steps.xml located […]/jbehave-tutorial/etsy-stories-java-spring/src/main/resources/etsy-steps.xml
and replace a FirefoxWebDriverProvider bean with a PropertyWebDriverProvider:

<bean id="driverProvider" class="org.jbehave.web.selenium.PropertyWebDriverProvider" >
</bean>

Step 3)
To set System Properties, edit Maven’s etsy-stories-java-spring module config file: […]/jbehave-tutorial/etsy-stories-java-spring/pom.xml
Follow this xpath to add the new props in the right place:

/pom:project pom:build/pom:plugins/pom:plugin/ pom:executions/pom:execution[2]/pom:configuration

                <systemProperties>
                    <property>
                        <name>browser</name>
                        <value>chrome</value>
                    </property>
                    <property>
                        <name>webdriver.chrome.driver</name>
                        <value>filepath/to/the/chromedriver/you/extracted/in/step1</value>
                    </property>
                </systemProperties>

ps. in case you’ll encounter problems solving all the dependencies while running the demo project, just add repos listed below to your main project Maven config file: ([…]/jbehave-tutorial/pom.xml)

  <repositories>
    <repository>
      <id>jbehave-web-repo</id>
      <name>jbehave web repo</name>
      <url>https://nexus.codehaus.org/content/groups/snapshots-group</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>codehausSnapshots</id>
      <name>Codehaus Snapshots</name>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
      </snapshots>
      <url>https://nexus.codehaus.org/content/groups/snapshots-group</url>
      <layout>default</layout>
    </pluginRepository>
  </pluginRepositories>

Cheers,
J

10 thoughts on “Replacing FF driver with Chrome in JBehave’s tutorial project

  1. Thank you for a very nice article.

    Would you expand on the instruction: Follow this xpath to add the new props in the right place:

    /pom:project pom:build/pom:plugins/pom:plugin/ pom:executions/pom:execution[2]/pom:configuration

    I seem to have put the systemProperties element in the wrong place because I don’t get the chrome browser to pop up when running. Firefox pops up. When I run with mvn -Pstable -Dbrowser=”chrome”, I do get the chrome browser to run, but I got anothe error:

    Started ChromeDriver
    port=30061
    version=20.0.1133.0
    log=C:\Users\212064501\workspace\JBehave-Dashboard-Tests\JBehave-Dashboard-Tests\mu-dashboard-selenium\java-spring\chromedriver.log
    .\test\automation\proxy_launcher.cc(108): error: Value of: app_launched
    Actual: 1
    Expected: AUTOMATION_SUCCESS
    Which is: 0
    Error while awaiting automation ping from browser process
    .\test\automation\proxy_launcher.cc(298): error: Value of: browser.get()
    Actual: false
    Expected: true

    If you have an idea of what the error message means, I would appreciate some pointers
    Kind regard,
    Tien

    • Hi Tien,

      Uhmm…I think this xapth is not even clear to me now 🙂
      What I meant is that:
      Go to that pom.xml file, find the systemProperties element and replace it with the one I’ve provided.
      This xpath was given just to explain where that element is in the XML structure. I hope that this one is more readable 🙂

      /project/build/plugins/plugin/executions/execution/configuration/systemProperties

      ps. I’m sorry for such a late answer but I was away for quite a long time.

      J

  2. Hi people.
    Thanks for the article. It was helpful for successfully execute stories with chrome 🙂
    PS: It works fine only with the first and second steps.
    Execute following command line in etsy’s project root directory:
    clean install -Pjava-spring,stable -Dwebdriver.chrome.driver=PathToTheDriver\chromedriver.exe -Dbrowser=chrome

  3. how to run the automation test cases in IE then? what is the change we need to make? any idea?

  4. Hi,

    I am trying to run tests on Selenuim web driver using Jbehave story files through Maven but i am getting the following error:

    Started ChromeDriver
    port=48363
    version=0.7
    log=D:\mu-test\mu-dashboard-test\JBehave Dashboard-Tests\mu-dashboard-selenium\java-spring\chromedriver.log
    org.jbehave.web.selenium.PerStoryWebDriverSteps.beforeStory() (FAILED)
    (org.jbehave.core.failures.BeforeOrAfterFailed: Method beforeStory (annotated with@BeforeStory in class org.jbehave.web.selenium.PerStoryWebDriverSteps) failed:org.openqa.selenium.WebDriverException: unknown error: chrome failed to start (Driver info: chromedriver=0.7,platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 1.25 seconds
    Build info: version: ‘2.28.0’, revision: ‘18309’, time: ‘2012-12-11 15:53:30’
    System info: os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version:’1.6.0_31′
    Driver info: org.openqa.selenium.chrome.ChromeDriver)

    I have made changes in pom.xml as well:

    browser
    chrome

    webdriver.chrome.driver
    D:\chromedriver2_win32_0.7\chromedriver.exe

    The maven command used to run the jbehave story file is:

    clean install -Pjava-spring,stable -Dwebdriver.chrome.driver=D:\chromedriver2_win32_0.7\chromedriver.exe -Dbrowser=chrome

    I also tried the below command:

    install -Pstable -DstoryFilter=”story_file_name” -Dbrowser=”chrome” -Dwebdriver.chrome.driver=”D:\chromedriver2_win32_0.7\chromedriver.exe”

    Any help is appreciated. Thanks.

    • Are you getting the same error when you don’t provide the path to the chrome driver in mvn cmd?

      • I am still getting the same error when I don’t provide the path.
        The commands I used are :

        install -Pstable -DstoryFilter=”Story_Name” -Dbrowser=”chrome”

        install -Pstable -DstoryFilter=”Story_Name” -Dbrowser=”chrome” -Dwebdriver.chrome.driver=”chromedriver.exe”

        clean install -Pjava-spring,stable -Dwebdriver.chrome.driver=E:\chromedriver2_win32_0.8\chromedriver.exe -Dbrowser=chrome -DstoryFilter=”Story_Name”

      • The problem was with the version of chrome driver. It worked fine on using the correct chrome driver! Thanks for all the great info on this blog 🙂

  5. Is there any way of configuring a firefox driver, chromedriver and IEdriver in beans, and using thread-safe code to run a test on all three browsers at the same time?

    I’m finding it very difficult to find any information on this but running parallel tests using jbehave and spring is a solution I am trying to set up.

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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s