用appium测试hybrid app时,appium提示error: INSTRUMENTATION_FAILED
来源:7-4 Hybrid App自动化脚本的实现
kurio
2017-09-07
# /usr/bin/python
# -*- coding:utf8 -*-
import unittest
import time
from appium import webdriver
class MyTestCase(unittest.TestCase):
def setUp(self):
self.desired_caps = {}
self.desired_caps['platformName'] = 'Android'
self.desired_caps['platformVersion'] = '6.0'
self.desired_caps['deviceName'] = '192.168.135.101:5555'
self.desired_caps['appPackage'] = 'mark.via'
self.desired_caps['appActivity'] = 'mark.via.ui.activity.BrowserActivity'
self.desired_caps['unicodeKeyboard'] = 'True'
self.desired_caps['resetKeybboard'] = 'True'
self.desired_caps['automationName'] = 'Selendroid'
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',self.desired_caps)
def testSearch(self):
# 进入baidu.com主页
self.driver.find_element_by_id('b0').click()
self.driver.find_element_by_id('b0').send_keys('baidu.com')
self.driver.find_element_by_id('b3').click()
time.sleep(5)
# switch 切换当前的上下文
print(self.driver.contexts) # contexts包含了native和webview两部分
# 切换到webview部分
#self.driver.switch_to.context('WEBVIEW_mark.via')
#print(self.driver.current_context)
time.sleep(5)
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()Appium中已配好application path,automation name也已设为为selendroid;
Appium版本为:AppiumForWindows_1_4_16_1
使用genymotion模拟器,采用6.0的系统,一直处于解锁状态
在Sublime Text3中直接运行脚本文件,Appium中提示以下错误:

写回答
3回答
-
可能是手机系统版本高于appium selendriod的版本。你有两种方式试一下,1.换一台低版本,4.4的手机试一下。2.或者用uiatomator模式,也就是native模式测试6.0的app,uiautormator在高版本上已经支持webview的测试。
012017-09-08 -
毫末
2017-09-26
和app有关系,如果开发用的不是内置webview就识别不出来,目前appium不支持第三方自己开发的webview
00 -
小黄莹哈哈哈
2017-09-26
我想问一下 为什么我的app只能有一个context
022017-09-26
相似问题
