问答 andriod --appium windows 报错 ,求救

丧尸没有牙齿 · 2017年06月05日 · 最后由 丧尸没有牙齿 回复于 2017年06月10日 · 2013 次阅读

代码配置项:

# urs/bin/python
# encoding:utf-8
import time
from appium import  webdriver
import unittest

class MyTestCase(unittest.TestCase):
    def setUp(self):

        self.desired_caps = {}
        self.desired_caps['platformName'] = 'Android'
        self.desired_caps['platformVersion'] = '4.4.2'
        self.desired_caps['deviceName'] = '127.0.0.1:62001'
        self.desired_caps['appPackage'] = 'com.example.zhangjian.minibrowser2'
        self.desired_caps['appActivity'] = '.myapplication.MainActivity'
        self.desired_caps["unicodeKeyboard"] = "True"
        self.desired_caps["resetKeyboard"] = "True"
        self.desired_caps["automationName"] = "Selendroid"
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)

    def testFindElements(self):
        input=self.driver.find_element_by_id("com.example.zhangjian.minibrowser2:id/url")
        input.send_keys("www.baidu.com")
        searchbutton = self.driver.find_element_by_id("com.example.zhangjian.minibrowser2:id/searchbutton")
        searchbutton.click()
        time.sleep(5)
        print self.driver.contexts
        self.driver.switch_to.context('WEBVIEW_0')
        print self.driver.current_context
        time.sleep(5)
        webinput=self.driver.find_element_by_xpath('//*[@id="kw"]')
        webinput.send_keys(u"游民星空")
        websearch=self.driver.find_element_by_xpath('//*[@id="su"]')
        websearch.click()
        time.sleep(5)
        firstresult=self.driver.find_element_by_xpath('//*[@id="1"]/h3/a[1]')
        self.assertTrue(u"大型单机游戏" in firstresult.text)
        # # 定位元素组
        # elements = self.driver.find_elements_by_xpath('//*[@id="page"]/div[2]/div[2]/div/table/tbody/tr/td')
        #
        # # 输出所有元素的名称
        # for el in elements:
        #   print el.text

        def tearDown(self):
            self.driver.quit()



if __name__ == '__main__':
    unittest.main()

启动后报错信息:

Error
Traceback (most recent call last):
File "D:\Python27\lib\unittest\case.py", line 320, in run
self.setUp()
File "G:\project\test\test\appdemo.py", line 19, in setUp
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
File "build\bdist.win-amd64\egg\appium\webdriver\webdriver.py", line 36, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "D:\Python27\lib\site-packages\selenium-2.53.6-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 90, in init
self.start_session(desired_capabilities, browser_profile)
File "D:\Python27\lib\site-packages\selenium-2.53.6-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\Python27\lib\site-packages\selenium-2.53.6-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium-2.53.6-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))

appium 后端错误信息:

info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: "D:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe" dump badging G:\TestDemo\app-debug_anr.apk
info: [debug] Rebuilt selendroid server does not exist, inserting modified manifest
info: [debug] Inserting selendroid manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\aapt.exe
info: [debug] Compiling manifest C:\Users\ADMINI~1\AppData\Local\Temp\com.example.zhangjian.minibrowser2\AndroidManifest.xml
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
info: [debug] Error: Required platform doesn't exist (API level >= 17)
at [object Object].ADB.compileManifest (D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:306:15)
at [object Object]. (D:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\selendroid.js:444:16)
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].ADB.checkSdkBinaryPresent (D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:116:5)
at [object Object]. (D:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\selendroid.js:442:30)
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\mkdirp\index.js:48:26
at FSReqWrap.oncomplete (fs.js:95:15)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}
info: <-- POST /wd/hub/session 500 494.293 ms - 220

补充:模拟器用的夜神模拟器,selenium-2.53.6,Appium-Python-Client-0.24,AppiumForWindows_1.4.16.1,Python27

不清楚是不是 selenium-2.53.6 版本过高造成的

共收到 2 条回复 时间 点赞

Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
info: [debug] Error: Required platform doesn't exist (API level >= 17)

恒温 回复

问题已经解决了,安装 API 17 能解决这个问题

恒温 关闭了讨论 06月10日 21:58
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册