我正在编写测试用例以检查Android Audio Recorder App的正常运行。 在一个这样的测试用例中,我希望我的Python代码在终端中显示录制的名称。
例如
所有TextView内容都具有相同的资源ID:text1
以下是 UIAutomatorViewer
的屏幕截图我使用的是Ubuntu 14.04。
我实现了滚动方法:
i = 0
while i <= 2:
for num in range(0,5):
element1 = WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, '//android.widget.ListView/android.widget.TextView[@index= %d]' % num)))
self.assertIsNotNone(element1)
print element1.text
element_to_tap = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.TextView[@index= 5]')
element_to_drag_to = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.TextView[@index= 0]')
self.driver.scroll(element_to_tap, element_to_drag_to)
i = i +1
在这里,我想在每次滚动之前显示5个列表元素。我现在有15个列表元素。
我现在得到的结果是:
Recording15.mp3
Recording14.mp3
Recording13.mp3
Recording12.mp3
Recording11.mp3
Recording6.mp3
Recording5.mp3
Recording4.mp3
Recording3.mp3
Recording2.mp3
Recording6.mp3
Recording5.mp3
Recording4.mp3
Recording3.mp3
Recording2.mp3
ok
中间的录音缺失 ..它完全滚动到底部..
我太接近答案,但太过分了......