有没有办法用计数器重写我的代码? 像:i = 0,el = name [i + 1] ??由于代码看起来太长而且有很多重复
name = wait.until(EC.presence_of_all_elements_located((By.ID, 'com.eas.android:id/text_username')))
try:
if name:
action.press(el=name[0]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)
action.press(el=name[1]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)
action.press(el=name[2]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)
action.press(el=name[3]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)
action.press(el=name[4]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)
action.press(el=name[5]).wait(2000).perform()
self.delUser()
btnBack.click()
time.sleep(2)