dream_18
liuxiangyu鱼
2018-12-18 13:49

appium测试微信公众号出现Could not find package com.android.chrome on the device的问题

  • webview
  • 微信小程序

1.新手,想在微信上面测试公众号,用的是appium+java,写了测试用例然后run的时候一直报错,没有找到解决方案,求大神指点,在线等!!

2.以下是我的代码:
初始化init类:

package appiumDemo;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;

public class InitAppium {

    public static AndroidDriver launchApp(String deviceName) throws MalformedURLException {

        // 设置自动化相关参数
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        // 使用哪种移动平台
        capabilities.setCapability("platformName", "Android");

        // 启动哪种设备,是真机还是模拟器
        capabilities.setCapability("deviceName", deviceName); // 如果是模拟器输入Android Emulator 红米note3 db3489d

        // 不要再次安装apk
        capabilities.setCapability("noReset", true);
        // 不用重新签名
        capabilities.setCapability("noSign", true);

        // 设置安卓系统版本
         capabilities.setCapability("platformVersion", "7.1");
        // 支持unicode键盘,输入中文设置
        capabilities.setCapability("unicodeKeyboard", "True");
        capabilities.setCapability("resetKeyboard", "True");

        // 设置app的主包名和主类名
         capabilities.setCapability("appPackage","com.tencent.mm");
         capabilities.setCapability("appActivity", "com.tencent.mm.ui.LauncherUI");

        ChromeOptions options = new ChromeOptions();
        options.setExperimentalOption("androidProcess", "com.tencent.mm:tools");
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);

        AndroidDriver driver = new AndroidDriver(new URL("http://169.254.82.105:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        return driver;

    }
}

测试类代码如下:

package appiumDemo;

import java.net.MalformedURLException;

import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;

public class NewTest {
    private AndroidDriver driver;
  @SuppressWarnings("static-access")
@Test
  public void f() {
      InitAppium init=new InitAppium();
      try {
        init.launchApp("c353ce90");

    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
      driver.findElementById("com.tencent.mm:id/azj").click();

  }
}

3.报错信息

[RemoteTestNG] failed to get TestNG version from class: java.lang.ClassNotFoundException: org.testng.internal.Version
[RemoteTestNG] now trying to parse the version from pom.properties
[RemoteTestNG] parsing TestNG version at jar:file:/E:/test/Tools/maven/maven-repository/org/testng/testng/6.1.1/testng-6.1.1.jar!/META-INF/maven/org.testng/testng/pom.properties
[RemoteTestNG] detected TestNG version 6.1.1
[TestNG] Running:
  C:\Users\vanchu\AppData\Local\Temp\testng-eclipse-1879104749\testng-customsuite.xml

FAILED: f
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not find package com.android.chrome on the device (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9.90 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'DESKTOP-GBO4D78', ip: '169.254.151.82', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: AndroidDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:87)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:111)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:72)
    at appiumDemo.InitAppium.launchApp(InitAppium.java:54)
    at appiumDemo.NewTest.f(NewTest.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:842)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1166)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:1178)
    at org.testng.TestRunner.privateRun(TestRunner.java:757)
    at org.testng.TestRunner.run(TestRunner.java:608)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1083)
    at org.testng.TestNG.run(TestNG.java:999)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6e6d5e: 1485 ms
[TestNG] Time taken by [TestListenerAdapter] Passed:0 Failed:0 Skipped:0]: 296 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@1f256fa: 109 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter@aa5eb0: 62 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@1ebec15: 8 ms

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答