【问题标题】:Success in running appium code from Android Studio?从 Android Studio 运行 appium 代码是否成功?
【发布时间】:2023-03-25 11:59:01
【问题描述】:

有没有人能够从 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. 一份工作解决方案的压缩包(如果可能)

非常感谢任何帮助。

【问题讨论】:

  • 1.我希望您了解 Android Studio 只是一个 IDE - 智能文本编辑器。您可以在记事本中编写代码,如果编写正确,它仍然可以工作。 Appium 是一个独立的 Selenium WebDriver 包装框架,用于移动设备。 2. 不。网络上到处都是例子——相信我。 3.您的应用程序似乎没有正确构建。 Appium 不依赖于"javax/xml/XMLConstants.class"
  • 我一直在用android studio写appium的脚本,没问题。您正在使用哪个框架?我正在使用 gradle,它工作正常。
  • @Gaurav 我正在使用 gradle
  • @KristapsMežavilks 即使我同意 appium 不依赖于 XMLConstants.class。此时构建仍然失败。我正在创建一个空白活动,添加一个简单的文本字段,然后在 gradle 文件中引用 io.appium 库。构建失败。
  • @Gaurav,我能够解决大部分错误。我确实通过删除 ~Library/Application Support/ 下的几个文件夹来重置 AndroidStudio。我想我在学习 AndroidStudio 时做了一些错误配置。我终于以 Dex 64K 限制错误结束。你也遇到过这种情况吗?我知道这可以通过拆分 dex 文件或使用 Proguard 来解决。我的观点只是针对一个小型测试应用程序,此限制已达到。当我在实际应用程序上使用 appium 时,我很担心。

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


【解决方案1】:

Appium SetupAndroid Studio 中的步骤:

  1. 下载 - Android Studio Appium Java Client Selenium Client Library Appium Server Install Java

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

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

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

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

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

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

此步骤取自 postvideo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多