• app应用appium框架简单自动化脚本


    【备注:与公司有关的信息改用[xxx]代替
    package connect.[xxx].com;
    import java.net.URL;
    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;

    public class Demo1 {
        public static  AndroidDriver  driver;
        @Test
        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);
                 driver.findElementById("com.[xxx].connect:id/me_rbtn").click();
                 Thread.sleep(1000);
                 driver.scrollTo("设置");
                 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();

    }
    }
  • 相关阅读:
    Ansible学习 Playbooks_1
    Ansible学习 ad-hoc命令
    Ansible学习 Patterns
    【转】对于SQL SERVER 事务日志已满问题整理
    【转】Apache配置正向代理与反向代理
    【转】Python的IDE和破解Code——pycharm
    【转】SQLServer 数据库变成单个用户后无法访问问题的解决方法
    【转】 尝试在数据库5 中提取逻辑页() 失败。该逻辑页属于分配单元xxx而非xxx
    【Oracle】Oracle版本导入导出问题
    【Java】eclipse导入war包二次开发
  • 原文地址:https://www.cnblogs.com/simplezhuo/p/9676701.html
Copyright © 2020-2023  润新知