quick start

Ayan Dave edited this page Oct 29, 2012 · 2 revisions

gS is built using Java and Maven. With some help it can be easily ported to .NET and Ruby.

Creating a new project

  1. Create a simple Maven project
  2. Add the following dependency to the pom.xml
    		\
     		\com.daveayan\
     		\gherkinsalad.core\
     		\${gherkinsalad.version}\
     		\jar\
     	\
  3. Select the version you would like to use. The latest version can be looked up in the sonatype maven repository

Create a page object

public class TwitterHomePage extends Component {
	public TwitterPage() {
		super.found(By.tagName("body"));
	}
}
public class TwitterLoginPage extends Component {
	public TwitterLoginPage() {
		super.found(By.tagName("body"));
	}
}

This defines the page object that represents the content within the body tag - basically the entire page.

Creating the step definition

public class TwitterSteps extends Component {
	TwitterLoginPage login_page = new TwitterLoginPage();
	TwitterHomePage home_page = new TwitterHomePage();

	@Given("^User A is logged in$")
	public void login() {
		super.launch_browser("firefox");
		login_page.login_as("username", "password");
	}
	@After
	public void teardown() {
		close_browser();
	}
}

The page object is created by simply using the constructor. Within the page object all the interactions will happen with the instance of browser that is currently available. The framework under the Component object handles it.

Within the page object

Working with HTML links and buttons

Clickable somelink = Link.find(By.id("someid"));
somelink.click_if_enabled();
The first line of code will create an object that has methods to perform click for the element that can be identified by the locator specified. The second line performs the clicking of the link only if it is enabled. For more information about Clickable check the javadocs

Working with Drop Downs
Selectable someDropDown = DropDown.find(By.id("someid"));
someDropDown.select_option_if_enabled("some text");

This will select the first option in the dropdown that has the text specified. For more information about Selectable check the javadocs

Working with Text Box and Text Area
TextEnterable someTextField = TextField.find(By.id("someid"));
someTextField.enter_text_if_enabled("text to enter");

This will find a text field, clear the existing text and enter new text in there.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.