XPath判断元素是否存在(兼容hmdriver2和uiautomator2) hmdriver2: d.xpath('xxx').exists() 是方法调用 uiautomator2: d.xpath('xxx').exists 是属性(bool值)
(self, xpath_str)
| 75 | return self._device.xpath(xpath_str) |
| 76 | |
| 77 | def xpath_exists(self, xpath_str): |
| 78 | """ |
| 79 | XPath判断元素是否存在(兼容hmdriver2和uiautomator2) |
| 80 | |
| 81 | hmdriver2: d.xpath('xxx').exists() 是方法调用 |
| 82 | uiautomator2: d.xpath('xxx').exists 是属性(bool值) |
| 83 | """ |
| 84 | if self.device_type == 'hmdriver2': |
| 85 | return self._device.xpath(xpath_str).exists() |
| 86 | else: |
| 87 | return self._device.xpath(xpath_str).exists |
| 88 | |
| 89 | def __call__(self, **kwargs): |
| 90 | """选择器定位,支持 text, resourceId, className 等""" |
no test coverage detected