- 导入包package: io.appium.java_client.pagefactory;
- id定位
@AndroidFindBy(id = "com.meta.box:id/iv_home_game_img")
public static List<HomeGameCellWidget> homePage;
public void search_barClick(){
getCabbie().pressOnElement(MainPageObjects.search_bar);
}
- text定位
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"搜索你喜欢的游戏吧\")")
public static MobileElement search_bar;
public void search_barClick_text(){
getCabbie().pressOnElement(MainPageObjects.search_bar);
}
- xpath定位
在这里插入代码片
- 兼容性,进阶 1个元素有多个属性定位,找到就点击
@AndroidFindAll({@AndroidFindBy(id = "com.meta.box:id/tv_home_search_hint"),@AndroidFindBy(uiAutomator = "new UiSelector().text(\"搜索你喜欢的游戏吧\")")})
public static MobileElement search_bar;
public void search_barClick_text(){
getCabbie().pressOnElement(MainPageObjects.search_bar);
}
|