Include Elements to Crawl

Basic Specification

To crawl the application, Crawljax needs to know which elements it should click.

The properties for crawling the can be set with CrawlSpecification
CrawlSpecification crawler = 
	new CrawlSpecification("http://www.google.com");
The set HTML elements that Crawljax should click can be set with click() in which the user specifies which tags should be clicked.
crawler.click("a");
The HTML elements that Crawljax should not click can be set with dontClick().
This set of HTML elements is excluded from the set inferred with click().
crawler.click("a").withAttribute("class", "noclick");;

Options

The set of HTML elements that should be included/excluded while crawling can be specified in detail with options. The options specify which criteria the HTML element should satisfy.

The textual content of the elements

withText(String text)
Only one text can be specified.
crawler.click("span").withText("Foo");

Attributes of the elements

withAttribute(String attributeName, String value)
Multiple attributes can be specified
crawler.click("a").withAttribute("class", "foo");
crawler.click("div").withAttribute("id", "bar")
	.withAttribute("class", "navigation");;

Location of elements.

underXpath(String xpathExpression)
With this method one can specify that an element should always be under an other element. This is done via specifying the parent element with an xpath expression. If the xpath expression does not return a node, the HTML element is not included.
Only one location can be specified.
NOTE: specify the tagnames in uppercase and attributes in lowercase
crawler.click("div").underXPath("//DIV[id='footer']");

Conditions

when(Condition...conditions)
Conditions can be specified which should be satisfied at the moment Crawljax wants to click on the element.
UrlCondition onLoginPage = new UrlConditions("#login");
crawler.when(onLoginPage).click("a").withText("Login");

Combinations

Different combinations can be used.
crawler.click("div").underXPath("//DIV[id='footer']")
	.withText("Info");
crawler.click("button").withText("save")
	.withAttribute("class", "contactform");