???????????????????????????????е??????????????selenium?????????д??????????????????????д??????????????????????????????????????????£????wiki?????飬????д??????????????
?????????selenium??UI?????????????????????????????????????????????Щ????????л??????????????????????Щ???????????? ???????????????????????????????????????д????????????????????????????????????????????????·?????????涼?????????? ??PageObject?????????????????浱??????????????????????????????????????????????????????????????л???????????? ?????????????????£??????????????~~?????????????????ε?IDE----Browser?????л??????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????Щ???????????? ????У???????????????????????????????д??????е??????????????????????????????????????????????????????????

1 public class PageObject {
2
3     private WebElement searchTypeSng;
4     private WebElement fromCity;
5     private WebElement toCity;
6     private WebElement fromDate;
7
8     public String calDate(int nextDays) {
9         // ???????? n ?????
10         Date date = DateUtils.addDays(new Date()?? nextDays);
11         // ??????????
12         return DateFormatUtils.ISO_DATE_FORMAT.format(date);
13     }
14
15     public void searchTrip(WebDriver driver??String from?? String to ??String date) {
16         BaseUtils.clearAndTypeString(driver??fromCity?? from);
17         BaseUtils.clearAndTypeString(driver??toCity?? to);
18         BaseUtils.clearAndTypeString(driver??fromDate?? date);
19         searchTypeSng.submit();
20     }
21
22 }
??????????У?
public class UsingPageObject {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver);
eventDriver.register(new MyWebDriverListener());
eventDriver.get("http://flight.qunar.com/");
PageObject object = PageFactory.initElements(driver?? PageObject.class);
String date = object.calDate(30);
object.searchTrip(driver??"????"?? "????"?? date);
}
}