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:
此行有多个标记
- AndroidDriver cannot be resolved to a type
- driver cannot be resolved to a variable
我还添加了gson jar和java客户端jar文件
答案 0 :(得分: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;
答案 1 :(得分: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);
答案 2 :(得分:0)
为(Java 7+)添加Apache Commons Lang 3.8.1 和Apache Commons Lang 2.6(需要Java 1.2或更高版本)
我的Java版本是8,并添加了Apache Commons Lang 3.8.1后解决了我的问题。