appium中判断某个元素是否存在
方法如下: def is_element_exist(self, element): source = self.driver.page_source print(source) if element in source: return True else: return False
调用方法示例:
比如,我在设备和安全这个页面,有以下元素,那么我判断有没有跳转到这个页面,就可以通过判断页面上有没有包含“设备和安全”这几个字,调用方法如下:
if self.is_element_exist("设备和安全"): print("元素存在") else: print("元素不存在。")