1. 程式人生 > >用python做自動化測試--Andriod App 的自動化-Appium的那些坑

用python做自動化測試--Andriod App 的自動化-Appium的那些坑

第一個坑, UiSelector.text裡面的字元必須是雙引號括起來,在Python裡面字元可以單引號,也可以雙引號。但UiSelector 是Andriod SDK 裡面的函式,Andriod SDK 是JAVA實現的,字元只能雙引號括起來。

driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()

第二坑,中文字元不需要加unicode指定。但你的檔案必須指定是utf-8編碼。

比如下面語句是不對的。

driver.find_element_by_android_uiautomator('new UiSelector().text(u"我的")').click()

檔案頭上必須加上:
#!/usr/bin/env python
#coding=utf-8