1. 程式人生 > 實用技巧 >十三、Python+appium獲取Toast內容

十三、Python+appium獲取Toast內容

需要獲取到toast彈框內容

改toast彈框的屬性有class等

1.可通過class屬性,使用xpath定位

text = self.find_element_xpath('//*[@class="android.widget.Toast"]').text

2.若上面的定位不到,可加一屬性

text = self.find_element_by_xpath('//*[@class="android.widget.Toast" and @index ="1"]').text