方法1.

try:
target="//android.widget.TextView[@text='立即體驗']"
element = WebDriverWait(dr,5,0.5).until(EC.presence_of_element_located((By.XPATH,target)))
except:
assert False, '%s元素没找到'%(target)

方法: 使用了 try + except  加上 显示等待 的方法,当查找不到元素的时候就报错

 

相关文章:

  • 2021-05-22
  • 2021-04-10
  • 2022-12-23
  • 2021-09-04
  • 2021-12-11
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
相关资源
相似解决方案