Selenium??PageFactory?????????е????
???????????? ???????[ 2014/5/28 9:26:43 ] ????????Selenium PageFactory ??????????
???????????????????????????????е??????????????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);
}
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11