current position:Home>Java Android mobile phone automatic basic learning element positioning

Java Android mobile phone automatic basic learning element positioning

2022-04-29 04:06:17On the cultivation of a test

  1. Import package package: io.appium.java_client.pagefactory;
  2. id location
     Insert picture description here
	// location 
	//AndroidFindBy  Interpreter , Find one of the elements and locate 
    @AndroidFindBy(id = "com.meta.box:id/iv_home_game_img")
    public static List<HomeGameCellWidget> homePage;
    // encapsulation 
    public void search_barClick(){
    
      	getCabbie().pressOnElement(MainPageObjects.search_bar);
    }
  1. text location
     Insert picture description here
	// location 
    @AndroidFindBy(uiAutomator = "new UiSelector().text(\" Search your favorite games \")")
    public  static MobileElement search_bar;
    // encapsulation 
    public void search_barClick_text(){
    
       // text Positioning mode 
       getCabbie().pressOnElement(MainPageObjects.search_bar);
    }
  1. xpath location
     Insert picture description here
 Insert a code chip here 
  1. Compatibility , Advanced 1 An element has multiple attribute locations , Click... When you find it
    @AndroidFindAll({
    @AndroidFindBy(id = "com.meta.box:id/tv_home_search_hint"),@AndroidFindBy(uiAutomator = "new UiSelector().text(\" Search your favorite games \")")})
    public  static MobileElement search_bar;
    // encapsulation 
    public void search_barClick_text(){
    
       // text Positioning mode 
       getCabbie().pressOnElement(MainPageObjects.search_bar);
    }
  1. The attributes of multiple elements are the same , Locate one of them
    //id The value is consistent with multiple attributes 
    @AndroidFindBy(id = "com.meta.box:id/iv_home_game_gif")
    public static List<MobileElement> fistPage;
    // encapsulation 
    public void fistPage_click(){
    
    // id Positioning mode 
    getCabbie().pressOnElement(MainPageObjects.fistPage.get(0));
    }

copyright notice
author[On the cultivation of a test],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/118/202204280600384402.html

Random recommended