热门IT资讯网

Appium Desktop录制测试用例

发表于:2024-11-23 作者:热门IT资讯网编辑
编辑最后更新 2024年11月23日,录制的脚本,可以拷贝到文件,用Pycharm打开加了一个隐式等待This sample code uses the Appium python clientpip install Appium-Pyt

录制的脚本,可以拷贝到文件,用Pycharm打开
加了一个隐式等待

This sample code uses the Appium python client

pip install Appium-Python-Client

Then you can paste this into a file and simply run with Python

from appium import webdriver

caps = {}
caps["platformName"] = "android"
caps["deviceName"] = "noblank"
caps["autoGrantPermissions"] = "true"
caps["appActivity"] = ".view.WelcomeActivityAlias"
caps["appPackage"] = "com.xueqiu.android"

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
driver.implicitly_wait(10)

el1 = driver.find_element_by_id("com.xueqiu.android:id/tv_skip")
el1.click()

el2 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.TextView")
el2.click()
el3 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.EditText")
el3.send_keys("alibaba")

driver.quit()

只要启动Appium Server, 就可以运行成功了!

可以使用Appium Desktop运行server,
或者在命令行直接运行appium启动server

0