appium自动化测试中,当一个任务点击完成之后在点击下一个任务,用python写一个判断
时间: 2024-03-26 14:38:27 浏览: 24
可以使用 Appium 提供的 `wait` 方法判断当前任务是否完成,如果完成则点击下一个任务。具体的实现可以参考以下代码:
```python
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# 等待任务完成
wait = WebDriverWait(driver, 10)
completion_button = wait.until(EC.element_to_be_clickable((By.ID, 'completion_button')))
completion_button.click()
# 点击下一个任务
next_button = driver.find_element_by_id('next_button')
if next_button.is_displayed() and next_button.is_enabled():
TouchAction(driver).tap(next_button).perform()
else:
print("Next button is not available")
```
其中,`completion_button` 是完成当前任务的按钮元素,`next_button` 是点击下一个任务的按钮元素。`wait` 方法会等待 `completion_button` 可以被点击后再继续执行下面的代码。如果 `next_button` 可见并且可用,则可以使用 `TouchAction` 点击该按钮。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)