由于初始化时要使用 appium 的键盘,所以设置了 desired_caps['unicodeKeyboard'] = True。然后就要在 teardown 中重设原来的输入法,但是当我使用了 desired_caps['automationName'] = 'uiautomator2'这个设置之后,每次执行 teardown 时,都无法重设输入法。。。。这是怎么一回事呢???有什么解决办法么???
代码如下:
@classmethod
def setUpClass(self):
print("setup begin")
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = DeviceName
desired_caps['platformVersion'] = PlatformVersion
desired_caps['appPackage'] = 'com.xxxxx'
desired_caps['appActivity'] = 'com.xxxxy'
desired_caps['noReset'] = True#无需每次都重新安装apk
#desired_caps['automationName']='selendroid'
desired_caps['automationName'] = 'uiautomator2'#据说这样就可以用xpath查找了?
#写了上面这句,在查看driver.available_ime_engines的时候就会出错,原因未知
desired_caps['unicodeKeyboard'] = True#设置使用appium的Unicode键盘
desired_caps["resetKeyBoard"]=True#该设置被appium忽略了,无用
global driver
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
#self.driver
print("setup over!")
@classmethod
def tearDownClass(self):
#driver = self.driver
print("teardown")
a= driver.available_ime_engines
print(a)
#重设输入法
driver.activate_ime_engine(a[0])#'com.iflytek.inputmethod/.FlyIME'
driver.quit()
出错信息如下:
Traceback (most recent call last):
File "E:\workspace\Pythonlearn1\src\salon\setUrl.py", line 57, in tearDownClass
a= driver.available_ime_engines
File "G:\Python36\lib\site-packages\appium\webdriver\webdriver.py", line 683, in available_ime_engines
return self.execute(Command.GET_AVAILABLE_IME_ENGINES, {})['value']
File "G:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "G:\Python36\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
File "G:\Python36\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "G:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, 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: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - ""
求支招~~