【备注:与公司有关的信息改用[xxx]代替】
package connect.[xxx].com;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import io.appium.java_client.android.AndroidDriver;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Demo1 {
public static AndroidDriver driver;
@Test
public void test() throws Exception {
public void test() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
// File classpathRoot = new File(System.getProperty("user.dir"));
// File appDir = new File(classpathRoot, "apps/[xxx]connet");
// File app = new File(appDir, "connect-[xxx]_connect.apk");
capabilities.setCapability("device","Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "H60_L21");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4");
// capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("unicodeKeyboard" ,"True");
capabilities.setCapability("resetKeyboard", "True");
capabilities.setCapability("appPackage", "com.[xxx].connect");
capabilities.setCapability("appActivity", "com.[xxx].activity.MainActivity_");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
// File classpathRoot = new File(System.getProperty("user.dir"));
// File appDir = new File(classpathRoot, "apps/[xxx]connet");
// File app = new File(appDir, "connect-[xxx]_connect.apk");
capabilities.setCapability("device","Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "H60_L21");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4");
// capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("unicodeKeyboard" ,"True");
capabilities.setCapability("resetKeyboard", "True");
capabilities.setCapability("appPackage", "com.[xxx].connect");
capabilities.setCapability("appActivity", "com.[xxx].activity.MainActivity_");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.findElementById("com.[xxx].connect:id/me_rbtn").click();
Thread.sleep(1000);
driver.scrollTo("设置");
driver.findElementByName("设置").click();
driver.findElementByName("设置").click();
Thread.sleep(2000);
driver.findElementByName("退出登录").click();
Assert.assertTrue("界面找不到:" + "登陆", driver.getPageSource().contains("登陆"));
driver.findElementById("com.[xxx].connect:id/login_password_et").sendKeys("asdasdasd");
driver.quit();
driver.quit();
}
}