forked from chenkan/Dagger
-
Notifications
You must be signed in to change notification settings - Fork 160
The First Demo
andrewleo edited this page Nov 1, 2013
·
6 revisions
This post will guide you create the first demo within 3 minutes.
- Eclipse with
git
&TestNG
plugins - Chrome installed under
default
path - Setup driver's path, please see this
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:
- Start Chrome
- Open Google
- Search 'github'
- Check result
- 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