Selenium??PageFactory?????????械????
???????????? ???????[ 2014/5/28 9:26:43 ] ????????Selenium PageFactory ??????????
??????????????????????????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???泻??????????????写???????????????????????????????????????????????????????????
??????
???路???
??????????????????
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