How to selectively run, in jBehave, stories tagged with multiple words in a meta field.

Prerequisites:
1) a working jBehave based project
This short tutorial is based on an jbehave-tutorial project available on github: https://github.com/jbehave/jbehave-tutorial.
To be precise I used the “java-spring” submodule from the “etsy-selenium” module, available here: https://github.com/jbehave/jbehave-tutorial/tree/master/etsy-selenium/java-spring, to run the modified story presented below.
2) Maven

OK, let’s consider a situation when we have stories belonging to multiple features, categories etc.
Below is an example story, tagged with multiple categories and features:

anExampleStoryWithMultipleWordsInAMetaKeyword.story

Meta:
@categories category1 category2 category3
@features feature1 feature2 feature3 feature_4

Scenario: scenario description
Given I'm on the homepage
....

Now, we’d like to run stories only for a selected category or a feature.
To accomplish this we’ll use the value pattern matching mechanism implemented in the jBehave meta matcher and described here.

Examples:
Run stories covering only category3:

mvn clean install -Dmeta.filter="+categories *category3*"

Run stories covering only feature_4:

mvn clean install -Dmeta.filter="+features *feature_4*"

And finally, run stories matching feature2 and category1:

mvn clean install -Dmeta.filter="+features *feature2* +categories *category1*"

Notice:
It seems that jBehave is not handling “-” hyphens in the keyword value properly, but it works fine with “_” underscores, separate words and camelCase notation 🙂

Selenium and self-signed SSL Certificates in Firefox [java / linux]

AAAARRGGHHHHHH!!!!!!!!….. Finally, I’ve managed to solve my problem with self-signed certificates in FF and Selenium.

I think I spend three days trying various methods, following tutorials and ‘hacking’ through the selenium source code, etc.
Maybe it’d take someone much less time than me, but what’s done is done, and let’s get crackin’ 🙂

A. Follow Girlie’s tutorial to create customized Firefox profile with few changes:

  1. in step no. 7 – remember not to use spaces in forlder names
  2. skip steps no. 11 & 12
  3. [OPTIONAL STEP] Configure FF according to Girlie’s suggestions
  4. Once you’re done with creating custom profile, go to the HTTPS site which troubles you with an invalid security certificate. Use “Add exception” button to add security exception.
  5. Close FF

B. Go to your FF custom profile folder (see A.1)

  1. If you skipped step A.3, then remove all files and folders except: cert8.db, cert_override.txt, key3.db
  2. If you followed Girlie’s suggestions in step A.3, then you can remove all files and folders except:
    • cert8.db, cert_override.txt, content-prefs.sqlite, key3.db, localstore.rdf, permissions.sqlite, prefs.js, secmod.db, XPC.mfasl, xpti.dat, XUL.mfasl
    • More information about contents of FF profile folder at: http://kb.mozillazine.org/Profile_folder_-_Firefox

C. Open your selenium project and add some new code:

private static Selenium selenium = new DefaultSelenium(String serverHost, int serverPort, String browserStartCommand, String browserURL);
private static SeleniumServer seleniumServer;
seleniumServer = new SeleniumServer();


/* 
* And here are the DRAGONS!!
* Short description:
* start with preparing new RemoteControlConfiguration and profile location
* then, change some default settings
* start selenium server
* and finally pass new configuration to Selenium 
*/

RemoteControlConfiguration rcc = seleniumServer.getConfiguration();
File profileLocation = new File("/path/to/your/custom/FF/profile");
rcc.setProfilesLocation(profileLocation);
rcc.setFirefoxProfileTemplate(profileLocation);
rcc.setReuseBrowserSessions(true);
seleniumServer.start();
selenium.start(rcc);

Hope this this work also for you.
J