Invariants

Invariants can be used to perform tests on the current state

Methods in CrawlSpecification

addInvariant(String description, Condition condition)
addInvariant(String description, Condition condition, Condition...preConditions)

Example 1

Use the generic conditions

addInvariant("No error messages", new NotRegexCondition("Error [0-9]+");

Example 2

Create your own condition

crawler.addInvariant("Test count myList", new ConditionAbstract(){

  @Override
    public boolean check(EmbeddedBrowser browser) {
      WebDriver driver = browser.getDriver();
      try{
        WebElement myList = driver.findElement(By.id("myList"));
        return new Select(myList).getOptions().size() > 0;
      }catch(NoSuchElementException e){
        //not found
        return true;
      }
    }
});