2017-05-27 65 views
0
public class Mobiletest { 
    private static AndroidDriver driver; 

    public static void main(String[] args) throws MalformedURLException, 
     InterruptedException { 

     DesiredCapabilities capabilities = new DesiredCapabilities(); 
     capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); 
     capabilities.setCapability("deviceName", "Redmi 1s"); 
     capabilities.setCapability("platformVersion", "4.4.4"); 
     capabilities.setCapability("platformName", "Android"); 
     // capabilities.setCapability("app", app.getAbsolutePath()); 
     capabilities.setCapability("appPackage", 
      "com.zipgo.customer"); 
     capabilities.setCapability("appActivity", 
      "SplashActivity"); 
     capabilities.setCapability(
      MobileCapabilityType.NEW_COMMAND_TIMEOUT, 
      "100"); 

     driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), 
      capabilities); 

它顯示了以下錯誤在Appium:driver = new AndroidDriver(new URL(「http://127.0.0.1:4723/wd/hub」),capabilities);在appium

在該行

- AndroidDriver cannot be resolved to a type 
- driver cannot be resolved to a variable 

我已經加入GSON罐子和java客戶端jar文件也

+0

你能顯示更多的代碼嗎?你如何定義'driver'變量? – nano

+0

以上是代碼 – Jagaur

+0

使用AppiumDriver代替Android驅動程序。它必須是「私有靜態AppiumDriver驅動程序;」 –

回答

0

你可能添加多個標記錯誤的依賴到你的項目中。

在我而言,這些都是我用我的Appium lib中的:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'junit:junit:4.12' 
    compile 'io.appium:java-client:4.1.2' 
    compile 'com.googlecode.json-simple:json-simple:1.1.1' 
    compile 'org.apache.httpcomponents:httpclient:4.5.1' 
    compile 'commons-lang:commons-lang:2.6' 
    compile 'com.google.code.gson:gson:2.7' 
    compile 'com.google.http-client:google-http-client:1.21.0' 
    compile 'com.testdroid:testdroid-api:2.9' 
    compile 'com.google.http-client:google-http-client-jackson2:1.21.0' 
} 

,然後創建AndroidDriver時,我輸入:

import io.appium.java_client.android.AndroidDriver; 
import io.appium.java_client.remote.MobileCapabilityType; 
import io.appium.java_client.remote.MobilePlatform; 
+0

好的任何鏈接下載所有這些jar文件 – Jagaur

0

嘗試我的例子:

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); 
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "8d1737f5"); 
// Need your unique device name, search in google, only for real device 
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1"); 
capabilities.setCapability(MobileCapabilityType.APP, "D://YourAPK.apk"); 
capabilities.setCapability("appPackage","com.sannacode.android.interviewtest"); 
capabilities.setCapability("appActivity", "com.sannacode.android.interviewtest.MainActivity"); 
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 
+0

>錯誤:未處理的錯誤:錯誤:ENOENT,沒有這樣的文件或目錄'C:\ Program Files文件(x86)\ Appium \ node_modules \ appium \「C:\ adt-bundle- (fs.js:761:18)處的錯誤(本地) >上的錯誤(windows-x86_64-20140321 \ sdk \ build-tools \ 19.1.0「\ build-tools' > – Jagaur

相關問題