mmichaelis
11/1/2011 - 9:37 PM

Examples of JBehave Stories

Examples of JBehave Stories

Scenario: Waiting
!--
Given I log in
When I wait for 3 seconds
Then I see the main page

Scenario: Reuse steps
!--
Given I log in
When ...
Then ...
Given I log in
Then ...

Scenario: Edge Cases
!--
Given I add <a> to <b>
Then I get <c>

Examples:     
|a|b|c|
|1|0|1|
|0|1|1|
|65535|1|65536|
...

Scenario: Address UI Elements
!--
Given I opened a document
When I focus the references
And I check the checkbox
And I press the delete button
Then the entry disappears
Scenario: Waiting
!--
Given I log in
When I wait for 3 seconds
Then I see the main page
Scenario: Waiting
!--
Given I log in
When I wait for 3 seconds because the main page needs to render first
Then I see the main page
@Then("I see the main page")
public void seeMainPage() {
  selenium.waitForCondition("selenium.browserbot.getCurrentWindow().someJavaScript",10000);
  [...]
)

@Then("I see the main page")
public void seeMainPage() {
  (new WebDriverWait(webDriver, 1000))
     .until(new ExpectedCondition<Object>() {
        public Object apply(WebDriver d) {
         JavascriptExecutor js = (JavascriptExecutor) webDriver;
         return js.executeScript("return someJavaScript");
        }
      });
  [...]
)