How can I use appium
to find a element which is not visible in a listview (maybe the element are located in the bottom,and I need to scroll many pages so that i can find the element )
I have used driver.scroll_find_element_by_name()
,but I got a error.
Appium:info: [debug] Didn't get a new command in 60 secs, shutting down...
My code is as follows:
def scroll_find_element_by_name(self, element_name, time_wait=0.5):
'''
@param:
@rtn: True/False,
@usage:
'''
#
width,height=self.getScreenResolution()
for i in range(maxScrollTimes):
#
try:
self.assertRaises(NoSuchElementException, self.driver.find_element_by_name, element_name)
print "Scroll down " + str(i+1) + ' time to find ' + element_name
except:
print 'SUCCESS: ' + element_name + ' found'
return True
self.driver.swipe(width / 2, 5 * height / 8, width / 2, 3 * height / 8, 1500)#
sleep(time_wait)
print 'UNSUCCESS: ' + element_name + 'NOT found'
return False