调试appium程序问题过程中,出现如下异常
java.lang.NoSuchMethodError: org.openqa.selenium.remote.HttpCommandExecutor.(Ljava/util/Map;Ljava/net/URL;Lorg/openqa/selenium/remote/http/HttpClient$Factory;)V
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:56)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:67)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:73)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:93)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:79)
at ContactsTest.setUp(ContactsTest.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
java.lang.NullPointerException
at ContactsTest.tearDown(ContactsTest.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
根据提示的异常信息提到junit、java-client、selenium-java、selenium-sever,以及网上搜索到的资料,可能是最原始的类库,也即junit、java-client、selenium-java、selenium-sever这几个jar文件导致的,那么我们现在要排除的就是对这几个文件的版本进行尝试更换,看看是否有异常信息改变或者改善,果然在进行更换selenium-java-2.44.0版本到selenium-java-2.6.0时,在运行脚本时,异常信息发生改变,如下
java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:143)
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 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:141)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at ContactsTest.setUp(ContactsTest.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
java.lang.NullPointerException
at ContactsTest.tearDown(ContactsTest.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
并且,此时,控制台有异常提示
三月 21, 2018 5:19:43 下午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
同时,在appium server端提示:如下
> info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_74)
> error: The following desired capabilities are required, but were not provided: platformName
> info: [debug] Got configuration error, not starting session
> info: [debug] Cleaning up appium session
> error: Failed to start an Appium session, err was: Error: The following desired capabilities are required, but were not provided: platformName
> info: [debug] Error: The following desired capabilities are required, but were not provided: platformName
> at [object Object].Capabilities.checkValidity (D:\Program Files (x86)\Appium\node_modules\appium\lib\server\capabilities.js:146:13)
> at [object Object].Appium.configure (D:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:238:35)
> at [object Object]. (D:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:118:10)
> at [object Object].Appium.start (D:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:129:5)
...
这里给的提示是,创建session失败,因为desired capabilities的属性platformName需要但没有提供。此处,基本可以说明,初步的问题已经基本得到解决,但也可能只是表面上,提示不同而已,并没有真正解决,我们暂且把它视为已解决。但同时也出现后面提示的错误,那我们再次尝试加上capabilities的platformName属性,代码如下
capabilities.setCapability("platformName", "Android");
然后再次尝试运行Junit Test,依然出现创建session失败问题,但此时appium server提示信息已经改变,如下
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: E:\\eclipseWorkspace\\TestDemo\\apps\\RandomContant.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'E:\\eclipseWorkspace\\TestDemo\\apps\\RandomContant.apk')","origValue":"Bad app: E:\\eclipseWorkspace\\TestDemo\\apps\\RandomContant.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'E:\\eclipseWorkspace\\TestDemo\\apps\\RandomContant.apk'"},"sessionId":null}
...
意思是说,app的路径错误,然后我对其他能正常运行的脚本进行对比,如:
可正常运行的脚本为
public class CalculatorTest {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "8SHQ31206614HB2078X");
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", ".Calculator");
AppiumDriver driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.findElement(By.name("1")).click();
driver.findElement(By.name("5")).click();
driver.findElement(By.name("9")).click();
driver.findElement(By.name("delete")).click();
driver.findElement(By.name("+")).click();
driver.findElement(By.name("6")).click();
driver.findElement(By.name("=")).click();
Thread.sleep(2000);
String result = driver.findElement(By.id("com.android.calculator2:id/formula")).getText();
System.out.println(result);
driver.quit();
}
}
异常运行脚本为
public class ContactsTest
{
/**
* setUp(这里用一句话描述这个方法的作用)
* TODO(这里描述这个方法适用条件 – 可选)
* TODO(这里描述这个方法的执行流程 – 可选)
* TODO(这里描述这个方法的使用方法 – 可选)
* TODO(这里描述这个方法的注意事项 – 可选)
* @param name
* @param @return 设定文件
* @return String DOM对象
* @Exception 异常对象
* @since CodingExample Ver(编码范例查看) 1.1
*/
private AppiumDriver driver;
@Before
public void setUp()
throws Exception
{
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/apps");
File app = new File(appDir, "RandomContant.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "0123456789ABCDEF");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("app", app.getAbsolutePath());
// capabilities.setCapability("app", "E:\\eclipseWorkspace\\TestDemo\\apps\\RandomContant.apk");
capabilities.setCapability("appPackage", "bbk.cly.RandomContacts");
capabilities.setCapability("appActivity", ".RandomContacts");
driver = new AppiumDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
System.out.println("App is launched!");
}
/**
* tearDown(这里用一句话描述这个方法的作用)
* TODO(这里描述这个方法适用条件 – 可选)
* TODO(这里描述这个方法的执行流程 – 可选)
* TODO(这里描述这个方法的使用方法 – 可选)
* TODO(这里描述这个方法的注意事项 – 可选)
* @param name
* @param @return 设定文件
* @return String DOM对象
* @Exception 异常对象
* @since CodingExample Ver(编码范例查看) 1.1
*/
@After
public void tearDown()
throws Exception
{
driver.quit();
}
@Test
public void test()
{
WebElement el = driver.findElement(By.name("生成"));
el.click();
System.out.println("App is done!");
// fail("Not yet implemented");
}
}
通过前后对比路径的代码,发现可正常运行的脚本,并不需要初始化设置app路径,也即没有
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/apps");
File app = new File(appDir, "RandomContant.apk");
capabilities.setCapability("app", app.getAbsolutePath());
这部分的代码,那么去掉这部分的代码,进行尝试,果然脚本已经开始可以运行,但,最后还是失败了,提示如下
注:为何不需要设置app路径?
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)","origValue":"Could not find a connected Android device."},"sessionId":null}
这里意思是无法连接上设备,我们知道,appium连接设备,是通过adb来连接的,那我们尝试在命令提示符cmd里输入adb devices连接
C:\Users\xxxxxxxx>adb devices
List of devices attached
0123456789ABCDEF device
然后再次运行脚本,又提示以下错误,似乎有电脑,一波N折,appium server提示如下:
> info: [debug] Attempting to kill all 'uiautomator' processes
> info: [debug] Getting all processes with 'uiautomator'
> info: [debug] executing cmd: D:\AutoTest\SmartSDK\SmartSDK\platform-tools\adb.exe -s 0123456789ABCDEF shell "ps 'uiautomator'"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> info: [debug] Cleaning up android objects
> error: Failed to start an Appium session, err was: Error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]
> info: [debug] Cleaning up appium session
> info: [debug] Error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]
> at D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1059:17
> at [object Object]. (D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
> at ChildProcess.exithandler (child_process.js:742:7)
> 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] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not extract PIDs from ps output. PIDS: [], Procs: [\"bad pid 'uiautomator'\"])","origValue":"Could not extract PIDs from ps output. PIDS: [], Procs: [\"bad pid 'uiautomator'\"]"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 16381.255 ms - 288
此处提示uiautomator进程出现问题,而uiautomator这个东西存在于SDK里面,这个SDK是公司为了某个自动化工具定制的,这让我们怀疑,这SDK是否出现了问题?当然这只是一个疑问。
而这里的关键信息是bad pid 'uiautomator',经过一番搜索后,得到:
Appium 1.4.13在Android 7上有bug,报错:
Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
原解决方案见:https://discuss.appium.io/t/support-version-android-n/10206/5
总结自己的解决方案:
原因:
1. adb.js 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
对应执行的指令是ps 'uiautomator', Android7不支持这个指令格式,所以执行结果是bad pid 'uiautomator'
目前Appium未对此进行处理,所以需要修改此指令的执行方式
即将 Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js 文件修改
this.shell("ps '" + name + "'", function (err, stdout) {
...
var procs = [];
var outlines = stdout.split("\n");
outlines.shift() //添加这行
...
于是再进行调试,好吧,还是有问题,出现了如下错误
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity)","origValue":"Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity"},"sessionId":null}
网上很多说法是:“要打开的activity不存在,activity路径错误,改为完整正确的activity路径”
仔细检查了好几遍发现,activity是存在的,activity路径也是正确的(当然这么低端的问题一般人也不会犯)
经过一番查找,问题解决如下:
注释掉setup中的如下两行:
capabilities.setCapability("appPackage", "xxx.xxx.xxx.activity");
capabilities.setCapability("appActivity", ".MainActivity");
但,如果前面没有添加app路径的话,会报No app set的错误,需要设置app路径,如我是:
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/apps");
File app = new File(appDir, "xxx.apk");
...
capabilities.setCapability("app", app.getAbsolutePath());
再次运行,问题解决了。
然而,在自己电脑上Android 7.0上运行脚本的时候,又出现了如下问题
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: C:\\Windows\\system32\\cmd.exe /s /c \"\"D:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe\" -s emulator-5556 install \"D:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"\"\nadb: failed to install D:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n)","killed":false,"code":1,"signal":null,"cmd":"C:\\Windows\\system32\\cmd.exe /s /c \"\"D:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe\" -s emulator-5556 install \"D:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"\"","origValue":"Command failed: C:\\Windows\\system32\\cmd.exe /s /c \"\"D:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe\" -s emulator-5556 install \"D:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"\"\nadb: failed to install D:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n"},"sessionId":null}
原因是,Appium 1.14不完全兼容Android 7.0,之前在公司的电脑上可以正常运行Android 7.0的机器,但用自己电脑运行另一台Android 7.0的机器,就出现如上所示的异常。
解决方法是,把测试机换成Android 6.0的机器,另外一种解决办法是,升级Appium 1.14到1.72版本,但这个解决方法尚未实验。
说明:运行测试的时候我们不需要指定package和activity 这些信息,Appium会从apk中提取这些信息。
见:https://github.com/appium/appium/issues/2981 中paymand 的解释:
Don't know about the apk info tool above, but you can always get that info using the aapt tool from Android SDK with the following command:
`adt/sdk/build-tools/android-4.4/aapt dump badging app.apk` Note: You shouldn't need to specify appPackage, appActivity, etc. since Appium should be able to extract those from the apk using the method above anyway.
其他Appium的问题和技巧, 大家可以参考: Appium的一些坑问题错误解决 与 技巧集锦
到此,初步运行的问题已经基本解决,文章有点长,本人才浅,欢迎指出不当指出。