Android webview 自動化測試Demo"chromedriverExecutable": "D:/BrowserDriver/chromedriver_win32_2.39/chromedriver.exe"
阿新 • • 發佈:2021-12-14
個人總結:
- desire_capabilitiy中不再需要配置“appPackage”、“appActivity”引數項,增加"browserName": "Browser"。如果chromedriver沒有放到appium的路徑下,則還需要配置"chromedriverExecutable"引數項,如下:
"chromedriverExecutable": "D:/BrowserDriver/chromedriver_win32_2.39/chromedriver.exe"
- 其他的元素定位跟PC端的web元素一樣。
- webdriver.find_element使用的時appium庫的。
Demo:
-
#!/usr/bin/python3.8.9 # -*- coding: utf-8 -*- # @Author : Tina Yu # @Time : 2021-12-12 17:16 from time import sleep from appium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait class TestAppWeb: def setup(self): desire_cap = { "platformName": "android", "platformVersion": "6.0", "deviceName": "127.0.0.1:7555", "browserName": "Browser", # "noReset": True, # 如果將chromedriver放到了appium的chromedriver路徑下,則不需要再指定 "chromedriverExecutable": "D:/BrowserDriver/chromedriver_win32_2.39/chromedriver.exe", } self.driver = webdriver.Remote("http://localhost:4723/wd/hub", desire_cap) self.driver.implicitly_wait(10) def teardown(self): self.driver.quit() def test_app_web(self): """ 1、開啟百度頁面 2、點選搜尋框 3、輸入appium關鍵字 4、進行搜尋 :return: """ self.driver.get("http://m.baidu.com") self.driver.find_element(By.XPATH, "//*[@for='index-kw']").click() self.driver.find_element(By.ID, "index-kw").send_keys("appium") search_button_locator = (By.ID, "index-bn") WebDriverWait(self.driver, 10, 1).until(expected_conditions.element_to_be_clickable(search_button_locator)) self.driver.find_element(*search_button_locator).click() sleep(3)
本文來自部落格園,作者:于慧妃,轉載請註明原文連結:https://www.cnblogs.com/fengyudeleishui/p/15687561.html