??????????????????????????e????????????写?????????TestNG???????????????main?????????写?????????????????效???
????????????????????????????????????????PageObject???屑????????Field???伞?
?????????-------------------------------------------------------------------------------------------------?????
????写???????????霉??????????????????危??????????????????械?????
?????? PageObject?????????????Field??????????????????????????????????????????????????????写??????selenium????? Id?????????????????胁?????????name???胁??????????????????????????????????????????????娣�???????????????? ????ID??name??Css???????selenium??????????????? ????????????
????selenium?????????????????????????????

 

1 public class PageObject {
2     private WebElement searchTypeSng;
3     @FindBy(name="fromCity")
4     private WebElement fromCity;
5     @FindBy(name="toCity")
6     private WebElement toWhere;
7     private WebElement fromDate;
8
9     public String calDate(int nextDays) {
10         // ???????? n ????? n=30
11         Date date = DateUtils.addDays(new Date()?? nextDays);
12         // ??????????
13         return DateFormatUtils.ISO_DATE_FORMAT.format(date);
14     }
15
16     public void searchTrip(WebDriver driver??String from?? String to ??String date) {
17         BaseUtils.clearAndTypeString(driver??fromCity?? from);
18         BaseUtils.clearAndTypeString(driver??toWhere?? to);
19         BaseUtils.clearAndTypeString(driver??fromDate?? date);
20         searchTypeSng.submit();
21     }
22
23 }

????????????????annotations?????????????????????selenium?????????????????????????位???? ??慰????????校?className??css??id??linkText??name??partialLinkText??tagName??xpath.
????????selenium??????2?????????????how?????????using???????????????????写?????????????????????????????榉�???????????榉�??
????????PageObject & PageFactory??????????写???????????PageFactory???泻??????????????写???????????????????????????????????????????????????????????