录制的脚本,可以拷贝到文件,用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
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/186415.html