2015-10-16 82 views
3

有没有人能成功地从Android Studio运行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 dependency解决了上面提到的构建错误,但我必须评论我的测试。

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

因此,我想知道

  1. 首先,如果appium和它的依赖与Android Studio的工作非常好
  2. 工作方案的拉链(如果可能)

任何帮助非常感谢。

+2

1.我希望你明白Android Studio只是一个IDE - 智能文本编辑器。您可以在记事本中编写代码,如果编写正确,它仍然可以工作。 Appium是一个独立的Selenium WebDriver包装框架,用于移动设备。 2.编号Web充满了例子 - 相信我。 3.看来你的应用程序没有正确的构建。 Appium对'“javax/xml/XMLConstants.class”'没有依赖性。 –

+1

我一直在使用android studio为appium编写脚本,并没有任何问题。你正在使用哪个框架?我使用gradle,它工作正常。 – Gaurav

+0

@Gaurav我正在使用gradle –

回答

0

的步骤Appium SetupAndroid Studio

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

  2. 安装Android工作室请按照给出的链接步骤

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

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

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

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

  7. 运行测试个案 点击构建变量选择单元测试开始与特定端口的appium服务器“4444”点击这里与USB调试上连接设备或启动模拟器。右击测试类,然后单击“运行”

从这个postvideo采取这一步骤。