各位大神,我运行 genymotion 模拟器的 apk 运行报错。
我的配置脚本为
#coding=utf-8
import os
import unittest,sys,time,re,datetime,HTMLTestRunner
from appium import webdriver
from time import sleep
import sys
#reload(sys)
#sys.setdefaultencoding('utf-8')
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class ContactsAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.3'
desired_caps['deviceName'] = '192.168.56.101:5555'
desired_caps['appPackage'] = 'com.android.dialer'
desired_caps['appActivity'] = '.DialtactsActivity'
self.driver = webdriver.Remote('http://192.168.10.157:4723/wd/hub', desired_caps)
def tearDown(self):
self.driver.close_app()
self.driver.quit()
def test_add_contacts(self):
self.driver.find_element_by_id('com.android.dialer:id/one').click()
self.driver.find_element_by_xpath("//android.widget.ImageButton[contains(@content-desc,'退格')]").click()
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(ContactsAndroidTests("test_add_contacts"))
#suite.addTest(IposCase("testmaters"))
timestr = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
filename = "D:\\appium\\appiumresult\\result_" + timestr + ".html"
print (filename)
fp = open(filename, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp,
title='测试结果',
description='测试报告'
)
#suite = unittest.TestLoader().loadTestsFromTestCase(ContactsAndroidTests)
#unittest.TextTestRunner(verbosity=2).run(suite)
runner.run(suite)
#g_browser.quit()
fp.close() #测试报告关闭
运行后 appium 控制台的 error 如下:
> Starting Node Server
> info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
> info: Appium REST http interface listener started on 192.168.10.157:4723
> info: [debug] Non-default server args: {"address":"192.168.10.157","logNoColors":true,"deviceName":"192.168.56.101:5555","platformName":"Android","platformVersion":"18","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":".DialtactsActivity","platformName":"Android","platformVersion":"4.3","deviceName":"192.168.56.101:5555","appPackage":"com.android.dialer"}}
> info: Client User-Agent string: Python-urllib/3.4
> info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
> info: [debug] Creating new appium session 064cdc4a-eb89-47fa-8f68-ef127b3eec32
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_11
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device 192.168.56.101:5555
> info: [debug] Setting device id to 192.168.56.101:5555
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 wait-for-device
> info: [debug] Retrying restartAdb
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 kill-server
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 devices
> info: [debug] 1 device(s) connected
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 wait-for-device
> info: [debug] Retrying restartAdb
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 kill-server
> error: Error killing ADB server, going to see if it's online anyway
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\BaiduYunDownload\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 devices
> Killed Node Server.
> Node Server Process Ended
反复的 [debug] Retrying restartAdb,有大神指点么~