• Appium——主从控制执行


    1.客户端(Eclipse)机器A, 服务端(appium、Genymotion)机器B

    2.设置Appium,Server Address为192.168.17.123,重新启动Appium

     

    3.在客户端机器A浏览器中输入:http://192.168.17.123:4723/wd/hub,

    说明配置成功。

    JAVA代码:

    其中driver= new AndroidDriver<WebElement>(new URL("http://192.168.17.123:4723/wd/hub"), capabilities);

    capabilities.setCapability("app", "F:\ContactManager.apk");F:\ContactManager.apk为服务端APK的路径

    public class AppiumTest {
        
        public AndroidDriver<WebElement> driver;
        
          @BeforeClass
          public void startTest() throws MalformedURLException{
              
             // File classpathRoot= new File(System.getProperty("user.dir"));
             // File appDir= new File(classpathRoot, "res/app");
            //  File app= new File(appDir, "ContactManager.apk");
              DesiredCapabilities capabilities= new DesiredCapabilities();
              capabilities.setCapability("automationName", "Appium");
              capabilities.setCapability("platformName","Android");
              capabilities.setCapability("deviceName","Android Emulator");
              capabilities.setCapability("platformVersion", "4.4.2");
              // 根据这个app capabilities,Appium会在启动测试之前安装好app到设备 
              capabilities.setCapability("app", "F:\ContactManager.apk");
              //设置安卓app的包名的capability,告诉appium你要运行哪个app。
              capabilities.setCapability("appPackage", "com.example.android.contactmanager");
              capabilities.setCapability("appActivity", ".ContactManager");
              driver= new AndroidDriver<WebElement>(new URL("http://192.168.17.123:4723/wd/hub"), capabilities);
          }
        
      @Test
      public void addContact() {
         // WebElement el= driver.findElement(By.xpath(".//*[@text='Add Contact']"));
          WebElement el = driver.findElementByAndroidUIAutomator("new UiSelector().text("Add Contact")");
          el.click();
          List<WebElement> textFieldsList= driver.findElementsByClassName("android.widget.EditText");
          textFieldsList.get(0).sendKeys("Some Name");
          textFieldsList.get(2).sendKeys("Some@example.com");
          driver.swipe(100, 500, 100, 100, 2);
          driver.findElementByXPath(".//*[@text='Save']").click();
     
      }
      
    
      @AfterClass
      public void afterClass() {
          driver.quit();
      }
       
    }
  • 相关阅读:
    boboJavaScript中innerHTML,innerText,value
    bobo JS中document.write(" ");
    bobo window.location.href
    bobojQuery选择器总结
    bobo jquery attr()方法
    bobowindow.location.hash 属性使用说明
    bobo$(function(){})和$(document).ready(function(){})
    bobo使用jQuery解析JSON数据
    MyBatis实现CRUD操作
    第一个MyBatis程序
  • 原文地址:https://www.cnblogs.com/hjhsysu/p/5777095.html
Copyright © 2020-2023  润新知