我必须了解Appium,我正在做一个“你好Appium”。
Windows8,Appium 1.4.13.1,IntelliJidea 14.1
WebDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"5554:Nexus_5");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "5.1");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"Android");
capabilities.setCapability(MobileCapabilityType.APP,"C:\\Users\\demitria\\Desktop\\testapp.apk");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void tapOnLoginNotFilledAnyThing(){
WebElement mob = driver.findElement(By.id("com.example.testapp:id/login_login_button"));
//here on mob WebElement I get java.lang.NullPointerException
//at MyFirstTest.tapOnLoginNotFilledAnyThing(MyFirstTest.java:78)
mob.click();
}
@Test
public void logInWithInvalidEmail(){
}
在appium上我有申请路径到
C:\ Users \用户demitria \桌面\ testapp.apk
Appium也适用于Appium检查员,但是当我启动测试时,模拟器没有任何事情发生(在应用程序未在模拟器中启动的意义上),但实际上测试已执行或至少我认为如此。我在IntelliJidea上也有一个警报图标。关于我做错了什么的任何想法
答案 0 :(得分:1)
解决。
1.-卸载IntelliJidea 14.1并安装Eclipse(当前版本),它提供了有关我所拥有的错误的更多信息而不是IntelliJ(你可以省略这个陡峭的)
2.-将我的.apk移动到 - > sdk \ build-tools \ ApiVersionYouAreUsingInAppium,我的情况C:\ Android \ sdk \ build-tools \ 22.0.1
3.-在Appium上设置新路径 - > Android设置 - >你的申请途径
修改如下所示的能力
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
File appDir = new File("C:\\Android\\sdk\\build-tools\\22.0.1\\");
File app = new File(appDir, "testapp.apk");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Nexus_5");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "5.1");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"Android");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE,"com.example.testapp");
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,"com.example.testapp.MainActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
答案 1 :(得分:0)
请尝试修改后的功能,如下所示。
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"5554:Nexus_5");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "5.1");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"Android");
capabilities.setCapability(MobileCapabilityType.APP,"C:\\Users\\demitria\\Desktop\\testapp.apk");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
如果您在设置MobileCapabilityType.APP
功能时随身携带APK文件,Appium会在运行时自动打开该应用的主要活动。