Skip to content
andrewleo edited this page Nov 1, 2013 · 6 revisions

This post will guide you create the first demo within 3 minutes.

Precondition

  • Eclipse with git & TestNG plugins
  • Chrome installed under default path
  • Setup driver's path, please see this

Steps

Checkout Dagger from github and start coding without any configuration.

Create demo such as:

package com.netease.demo;

import com.netease.dagger.BrowserEmulator;

public class GoogleSearch {

	public static void main(String[] args) {

		String googleUrl = "http://www.google.com";
		String searchBox = "//input[@name='q']";
		String searchBtn = "//input[@name='btnK']";

		BrowserEmulator be = new BrowserEmulator();
		be.open(googleUrl);
		be.type(searchBox, "github");
		be.click(searchBtn);
		be.expectTextExistOrNot(true, "https://github.com/", 5000);
		be.quit();
	}
}

That's all. And you can easily understand the story:

  1. Start Chrome
  2. Open Google
  3. Search 'github'
  4. Check result
  5. Quit Chrome

As we said:

Dagger is a design style at last: the framework and the testcases based on it both should be light and straightforward

And an important convention:

Dagger only uses xpath to locate page element

Clone this wiki locally