【发布时间】:2017-12-26 02:40:58
【问题描述】:
我正在使用 APPIUM 自动测试 WECHAT.apk。但是在使用带有 eclipse IDE 的 appium 服务器时,我可以测试打开文件。
package com.qa.test;
import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.AssertJUnit;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.appium.java_client.android.AndroidDriver;
//import org.junit.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
public class appiumlogin {
RemoteWebDriver driver = null;
//private RemoteWebDriver webDriver;
@BeforeTest
public void beforeTest() throws Exception{
//install ne apk
try{
//File appDir = new
File("C://Users//SYS//Downloads//new//android//Android//sdk//platform-tools");
//File app = new File(appDir, "wechat.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","emulator-5554");
capabilities.setCapability("platformVersion", "4.3.1");
capabilities.setCapability("appPackage","com.tencent.mm");
capabilities.setCapability("appActivity","com.tencent.mm.ui.LauncherUI");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}catch(IOException e){
e.printStackTrace();
}
}
@Test
public void wechatinstall(){
WebElement Login = driver.findElement(By.id("com.tencent.mm:id/cgw"));
Login.click();
WebElement LogIn = driver.findElement(By.id("com.tencent.mm:id/g0"));
Assert.assertEquals("true", LogIn.getAttribute("enabled"));
WebElement mobilenumber = driver.findElement(By.id("com.tencent.mm:id/bun"));
Assert.assertEquals("true", mobilenumber.getAttribute("enabled"));
Assert.assertEquals("9036103153", mobilenumber.getText());
WebElement password = driver.findElement(By.id("com.tencent.mm:id/gz"));
Assert.assertEquals("true", password.getAttribute("enabled"));
Assert.assertEquals("lachudarling", password.getText());
WebElement Login1 = driver.findElement(By.id(" com.tencent.mm:id/ac6"));
Login1.click();
Assert.assertEquals(" ", mobilenumber.getText());
Assert.assertEquals(" ", password.getText());
}
@AfterTest
public void afterTest() throws InterruptedException{
driver.quit();
}
}
在这个 pgm 中,我测试了 apk 文件,它只是打开了一个应用程序。但没有选择登录按钮。
【问题讨论】:
-
好像是“com.tencent.mm:id/ac6”,前面有空格,所以不行?
标签: android eclipse selenium appium