【前置】
python 安装正常
UIautomator 2 也安装成了, 在 C:\Users\Administrator\node_modules_appium-uiautomator2-server@3.1.1@appium-uiautomator2-server\目录下可以查看到 appium-uiautomator2-server-debug-androidTest.apk 和 appium-uiautomator2-server-v0.3.0.apk 包的。
selenium 也安装了, 使用 pip show selenium 能查看到版本号等

【程序】
from appium import webdriver
from selenium.common.exceptions import NoSuchElementException

desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='5.1.1'
desired_caps['deviceName']='127.0.0.1:62025'
desired_caps['app']=r'E:\BaiduNetdiskDownload\App\kaoyan3.1.0.apk'
desired_caps['appPackage']='com.tal.kaoyan'
desired_caps['appActivity']='com.tal.kaoyan.ui.activity.SplashActivity'
desired_caps['noReset']='True'
desired_caps['unicodeKeyboard']='True'
desired_caps['resetKeyboard']='True'
desired_caps['automationName']='uiautomator2'

driver=webdriver.Remote('http://localhost:4723/wd/hub,desired_caps')
driver.implicitly_wait(2)

def Check_CancelBtn():
print('Check Cancel Button')
try:
CancelBtn=driver.find_element_by_id('android:id/button2')
except NoSuchElementException:
print('No Cancel button')
else:
CancelBtn.click()
def Check_SkipBtn():
print('Check Skip button')
try:
SkipBtn=driver.find_element_by_id('com.tal.kaoyan:id/tv_skip')
except NoSuchElementException:
print('No Skip button')
else:
SkipBtn.click()
Check_CancelBtn()
Check_SkipBtn()
【报错如下】
E:\python\python.exe C:/Users/Administrator/PycharmProjects/untitled/Appium/Capability.py
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/untitled/Appium/Capability.py", line 16, in
driver=webdriver.Remote('http://localhost:4723/wd/hub,desired_caps')
File "E:\python\lib\site-packages\appium\webdriver\webdriver.py", line 97, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "E:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in init
self.start_session(capabilities, browser_profile)
File "E:\python\lib\site-packages\appium\webdriver\webdriver.py", line 136, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, parameters)
File "E:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "E:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot create property 'replace' on boolean 'true'
【疑问】
Cannot create property 'replace' on boolean 'true'
不知道这个 property ‘replace’ 是指哪里的设置
我是刚开始自学 appium 和 python, 请大神指教,谢谢!


↙↙↙阅读原文可查看相关链接,并与作者交流