我正在尝试使用genymotion运行测试脚本,但Appium会抛出一些错误

时间:2017-02-26 22:33:27

标签: selenium appium genymotion

PLZ帮帮我

****这是我的代码****

public class demo1 {
    public WebDriver driver;
    @Test
    public void test() throws MalformedURLException
    {


        String apkpath=("C:\\App\\bookmyshow.apk");
        File app=new File(apkpath);

        final DesiredCapabilities cap = new DesiredCapabilities();

        cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
        cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4.4");
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Google Nexus 5 - 4.4.4 API 19 - 1080x1920");
        cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
        cap.setCapability("appPackage", "com.bookmyshow.apk"); 
        cap.setCapability("appActivity", "bookmyshow.apk");
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        }

}

=============================================== =================================

Appium错误

=============================================== =========================

  

使用以下命令启动Appium服务器:C:\ Program Files(x86)\ Appium \ node.exe lib \ server \ main.js --address 127.0.0.1 --port 4723 --app C:\ App \ bookmyshow。 apk --no-reset --avd-args 192.168.71.101:5555 --platform-name Android --platform-version 19 --automation-name Appium --log-no-color   info:欢迎来到Appium v​​1.4.16(REV ae6877eff263066b26328d457bd285c0cc62430d)   info:Appium REST http接口监听器在127.0.0.1:4723上启动   info:[debug]非默认服务器args:{" app":" C:\ App \ bookmyshow.apk","地址":" 127.0.0.1"" NORESET":真," logNoColors":真," avdArgs":" 192.168.71.101:5555&#34 ;," platformName":" Android和#34;" platformVersion":" 19"" automationName":&#34 ; Appium"}   info:Console LogLevel:debug   信息: - > POST / wd / hub / session {"功能":{" desiredCapabilities":{" app":" C:\ App \ bookmyshow.apk&# 34;," appPackage":" com.bookmyshow.apk"" appActivity":" bookmyshow.apk""&platformVersion #34;:" 4.4.4"," platformName":" Android"," deviceName":" Google Nexus 5 - 4.4.4 API 19 - 1080x1920"}," requiredCapabilities":{}}," desiredCapabilities":{" app":" C: \ APP \ bookmyshow.apk"" appPackage":" com.bookmyshow.apk"" appActivity":" bookmyshow.apk&#34 ;," platformVersion":" 4.4.4"" platformName":" Android和#34;" DEVICENAME":& #34; Google Nexus 5 - 4.4.4 API 19 - 1080x1920"}," requiredCapabilities":{}}   info:客户端用户代理字符串:Apache-HttpClient / 4.5.2(Java / 1.8.0_112)   info:[debug]使用所需大写的本地应用程序:C:\ App \ bookmyshow.apk   info:[debug]创建新的appium会话25722b10-f229-42af-a64c-347ebbe9c25f   info:启动android appium   info:[debug]获取Java版本   info:Java版本是:1.8.0_112   info:[debug]检查adb是否存在   info:[debug]使用来自C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe的adb   info:[debug]使用快速重置?假   info:[debug]准备会话设备   info:[debug]检查app是否确实存在   info:检索设备   info:[debug]试图找到一个连接的Android设备   info:[debug]获取连接设备...   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe devices   info:[debug] 2个设备已连接   信息:找到设备192.168.71.101:5555   info:[debug]将设备ID设置为192.168.71.101:5555   info:[debug]等待设备准备就绪并响应shell命令(timeout = 5)   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 192.168.71.101:5555 wait-for-device   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 192.168.71.101:5555 shell" echo' ready&#39 ;"   info:[debug]启动logcat捕获   info:[debug]获取设备API级别   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 192.168.71.101:5555 shell" getprop ro.build.version.sdk& #34;   info:[debug]设备处于API级别19   info:设备API级别为:19   info:[debug]为语言提取字符串:default   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 192.168.71.101:5555 shell" getprop persist.sys.language&#34 ;   info:[debug]当前设备persist.sys.language:en   info:[debug] java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ _jars \ appium_apk_tools.jar" " stringsFromApk" " C:\应用\ bookmyshow.apk" " C:\用户\圣\应用程序数据\本地\ TEMP \ com.bookmyshow.apk"恩   info:[debug]没有strings.xml用于语言' en',获取默认的strings.xml   info:[debug] java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ _jars \ appium_apk_tools.jar" " stringsFromApk" " C:\应用\ bookmyshow.apk" " C:\用户\圣\应用程序数据\本地\ TEMP \ com.bookmyshow.apk"   警告:从apk获取strings.xml时出错   info:[debug]线程中的异常" main" brut.androlib.AndrolibException:无法从文件加载resources.arsc:C:\ App \ bookmyshow.apk     在brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:608)     在brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:74)     在brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:66)     at io.appium.apktools.StringsXML.run(StringsXML.java:84)     在io.appium.apktools.Main.main(Main.java:31)   引起:brut.directory.DirectoryException:java.util.zip.ZipException:archive不是ZIP存档     在brut.directory.ZipRODirectory。(ZipRODirectory.java:54)     在brut.directory.ZipRODirectory。(ZipRODirectory.java:37)     在brut.androlib.res.util.ExtFile.getDirectory(ExtFile.java:55)     在brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:605)     ......还有4个   引起:java.util.zip.ZipException:archive不是ZIP存档     在org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory32(ZipFile.java:717)     在org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:672)     在org.apache.commons.compress.archivers.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:406)     在org.apache.commons.compress.archivers.zip.ZipFile。(ZipFile.java:206)     在org.apache.commons.compress.archivers.zip.ZipFile。(ZipFile.java:182)     在org.apache.commons.compress.archivers.zip.ZipFile。(ZipFile.java:143)     在brut.directory.ZipExtFile。(ZipExtFile.java:28)     在brut.directory.ZipRODirectory。(ZipRODirectory.java:52)     ......还有7个

     

警告:无论如何都无法获得字符串   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 192.168.71.101:5555 shell" echo' {}& #39; > /data/local/tmp/strings.json"   info:[debug]检查aapt是否存在   info:[debug]使用来自C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe的aapt   info:[debug]从清单中检索进程。   info:[debug]执行cmd:C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe dump xmltree C:\ App \ bookmyshow.apk AndroidManifest.xml   警告:W / zipro(6068):打开存档时出错C:\ App \ bookmyshow.apk:文件无效   错误:转储失败,因为找到了资源AndroidManifest.xml

     

info:[debug]将应用程序进程设置为:com.bookmyshow.apk   info:[debug]不卸载应用程序,因为服务器未启动--full-reset   info:[debug]检查C:\ App \ bookmyshow.apk的应用程序证书。   info:[debug]执行cmd:java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ verify.jar" C:\软件\ bookmyshow.apk   info:[debug]应用程序未使用调试证书签名。   info:[debug]辞职apk。   info:[debug]执行cmd:java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ sign.jar" C:\ App \ bookmyshow.apk --override   info:[debug]停止logcat捕获   info:[debug] Logcat终止,代码为null,信号为SIGTERM   info:[debug]发送shutdown命令,等待UiAutomator停止...   警告:UiAutomator没有足够快地关闭,称它已经消失了   info:[debug]清理android对象   info:[debug]清理appium会话   错误:无法启动Appium会话,错误是:错误:命令失败:C:\ WINDOWS \ system32 \ cmd.exe / s / c" java -jar" C:\ Program Files(x86) \ appium \ node_modules \ appium \ node_modules \ appium-ADB \罐\ sign.jar" C:\ App \ bookmyshow.apk --override"   java.util.zip.ZipException:打开zip文件时出错   java.util.zip.ZipException:打开zip文件时出错     at java.util.zip.ZipFile.open(Native Method)     at java.util.zip.ZipFile.open(Native Method)     在java.util.zip.ZipFile。(ZipFile.java:219)     在java.util.zip.ZipFile。(ZipFile.java:149)     在java.util.zip.ZipFile。(ZipFile.java:149)     在java.util.jar.JarFile。(JarFile.java:166)     在java.util.jar.JarFile。(JarFile.java:145)     at s.Sign.sign(Sign.java:441)     在s.Sign.main(Sign.java:532)

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
     

info:[debug]响应客户并出现错误:{" status":33," value":{" message":" A无法创建新会话。 (原始错误:命令失败:C:\ WINDOWS \ system32 \ cmd.exe / s / c \" java -jar \" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ sign.jar \" C:\ App \ bookmyshow.apk --override \" \ njava.util.zip.ZipException:打开zip文件时出错\ r \ n \ tat java.util.zip.ZipFile.open(Native Method)\ r \ n \ tat java.util.zip.ZipFile。(ZipFile.java:219)\ r \ n \ tat java.util.zip.ZipFile。( ZipFile.java:149)\r\n\tat java.util.jar.JarFile。(JarFile.java:166)\ r \ n \ tat java.util.jar.JarFile。(JarFile.java:145)\ r \ n \ n \ tat s.Sign.sign(Sign.java:441)\ r \ n \ tat s.Sign.main(Sign.java:532)\ r \ n)"," kill&# 34;:假,"代码":1,"信号":空," CMD":" C:\窗口\ system32 \ cmd.exe的/ s / c \" java -jar \" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ sign.jar \" C:\ App \ bookmyshow.apk --override \""," origValue":"命令失败:C:\ WINDOWS \ system32 \ cmd.exe / s / c \" java -jar \" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ sign.jar \" C:\ App \ bookmyshow.apk --override \" \ njava.util.zip.ZipException:打开zip文件时出错\ r \ n \ tat java.util.zip.ZipFile.open(Native Method)\ r \ n \ tat java.util.zip.ZipFile。(ZipFile.java:219)\ r \ n \ tat java.util.zip.ZipFile。(ZipFile.java:149)\ r \ n \ tat java.util .jar.JarFile。(JarFile.java:166)\ r \ n \ tat java.util.jar.JarFile。(JarFile.java:145)\ r \ n \ tat s.Sign.sign(Sign.java:441 )\ r \ n \ tat s.Sign.main(Sign.java:532)\ r \ n"}," sessionId":null}   info:< - POST / wd / hub / session 500 11155.864 ms - 1554

=============================================== ==========================

** img ** Android Setting

=============================================== =================

CMD:adb devices

C:\ Users \ Santo> C:\ Users \ Santo \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe devices 附加设备列表 192.168.71.101:5555设备

1 个答案:

答案 0 :(得分:0)

您未在@Test下设置所需的功能。创建一个单独的setUp()函数来设置所需的功能,该函数需要注释为@Before。