android - 从 Android Studio 成功运行 appium 代码?

标签 android android-studio android-gradle-plugin appium

有没有人能够从 Android Studio 成功运行 appium 测试?如果您能将它的工作样本传给我,我将不胜感激。

我已经尝试让设置运行两个多星期了。在尝试运行测试时,构建在 preDexDebug 步骤失败并出现以下错误

trouble processing "javax/xml/XMLConstants.class"
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on.
However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform.
It is also often of questionable legality. If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the \"--core-library\" option to suppress this error message.
.......... and the error goes on.

我尝试使用 --core-library 选项。但是错误仍然存​​在。

我正在使用 maven 来收集 appium 的依赖项。

compile 'io.appium:java-client:3.2.0'

我的主要问题:appium 及其依赖项是否与 Android Studio 兼容?因为它在 Eclipse 上运行非常流畅

注释 io.appium 依赖项可以解决上述构建错误,但我必须注释我的测试。

在耗尽我自己的知识之后,我阅读了一些关于我的问题的关于 stackoverflow 和其他互联网资源的帖子,但没有具体的解决方案。它更像是一种试探机制,说“这可能有效”。我试过了,但没有成功。

所以我想知道

  1. 首先,如果 appium 及其依赖项与 Android Studio 配合得很好
  2. 工作解决方案的 zip(如果可能)

非常感谢任何帮助。

最佳答案

Android Studio 中设置 Appium 的步骤:

  1. 下载 - Android Studio Appium Java 客户端 Selenium 客户端库 Appium 服务器安装 Java

  2. 安装 Android Studio 请按照链接中给出的步骤

  3. 在windows机器上一步一步安装android studio 点击这里 安装android studio后,打开android studio并创建一个新项目 - 如何创建android项目?

  4. 将下载的 Appium jar 添加到您的项目中 - 单击 project -> 单击 app -> 复制 lib 中的所有 jar。选择除 Selenium、Java 客户端和 Junit Jar 之外的复制的 jar,然后右键单击它并单击“添加为库”。

  5. 在应用程序中单击 build.gradle,您将看到添加的所有库,如下图所示添加 junit:4.12.Sync 项目或重新构建项目。它应该显示“Build Successful Message”

  6. 现在您已准备好编写您的第一个测试用例 - 右键单击​​包并单击“创建 Java 类”。复制给定的测试用例样本。

  7. 运行测试用例- 单击构建变体选择单元测试使用特定端口“4444”启动 appium 服务器单击此处连接设备并打开 USB 调试或启动模拟器。右键点击测试类,点击“运行”

此步骤取自 postvideo .

关于android - 从 Android Studio 成功运行 appium 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33170431/

相关文章:

android - WebView 返回

android - 使用Facebook Audience Network时Android Studio错误

android - 升级到 Android Studio 2.3 后出现 "package android.support.multidex does not exist"

java - 我可以通过常规 J​​ava main 方法从 Android 项目运行纯 Java 代码的子集吗?

android - 使用 gradle 2.14.1 时无法获得未知属性 'assembleRelease'

android - 使用 Android Gradle 插件 0.7.3 在项目中添加预构建的 .so 文件

android - ZXing 可以在带有加密二维码的 Android 中使用吗?

安卓:ActivityNotFoundException

android - Gradle 同步时间太长 Firebase-core 无法 HEAD 状态代码 409

java - Android 如何以编程方式获取图像按钮的 ID?