Appium(五)常用方法

Appium常用方法

1、Appium常用的方法一般以下几种

  • click
  • text
  • get_attrbute
  • send_keys
  • page_source
  • TouchAction

2、用法

  • click

        1.self.driver.find_element_by_id("").click()找到元素并点击

  • text

       1.self.driver.find_element_by_id("").text找到元素,获取到当前元素的文本

  • get_attrbute

       1.self.driver.find_element_by_id("").get_attribute("xx"),get_attribute的参数为:index,text,resource-id,clas,package,contene-desc

  • send_keys

       1.self.driver.find_element_by_id("").send_keys("")定位到输入框,输入内容

  • page_source

       1.self.driver.page_source获取当前界面的元素信息,如果当前式activity获取到的是xml布局信息,如果是webview且开启了debug模式获取到的就是html信息

  • TouchAction
  1. 触摸操作
  2. 方法long_press(el,times)长按某个元素times毫秒或坐标long_press(x,y,times),move_to(el)移动到某个元素货坐标move_to(x,y),wait(times)等待毫秒,tab(el),tab(x,y)

          点击某个元素或坐标,release()结束屏幕上的一系列操作,perform()释放,将执行操作发送到服务器

      3.具体用法TouchAction(self.driver).tab().release().perform(),具体可根据自己的需求来组合操作

3、Toast定位

  1.    
    def toast_locator():
        return (By.XPATH,"//*[@class='android.widget.Toast']")
    

     

posted @ 2020-06-05 22:57  guoke1001  阅读(358)  评论(0编辑  收藏  举报