2015-10-16 79 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採取這一步驟。