• Appium对手机chrome浏览器操作


    appium操作chrome浏览器

    1.安卓手机下载手机版chrome浏览器

    2.Andriod setting中选择“chrome”

    3.通过css定位得到百度输入框为:#index-kw

    4.编写代码

    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.TouchAction;
    
    import org.junit.*;
    import org.junit.Before;
    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.remote.RemoteWebDriver;
    import org.openqa.selenium.WebDriver;
    public class chrome {
        private AppiumDriver driver;
        private static WebElement element = null;
        int port=22;
        String url="";
        @Before
        public void setUp() throws Exception {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName","xx");xx->手机设备号
            capabilities.setCapability("platformVersion", "4.4");
            capabilities.setCapability("unicodeKeyboard", true); 
            capabilities.setCapability("resetKeyboard", true);
            capabilities.setCapability("browserName", "Chrome");    
            capabilities.setCapability("appPackage", "com.android.browser");
            capabilities.setCapability("appActivity", ".BrowserActivity");
            capabilities.setCapability("unicodeKeyboard",true);
            capabilities.setCapability("resetKeyboard",true);
            driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    
       
        }
     @After
        public void tearDown() throws Exception {
            driver.quit();
        }
    @Test
        public void addContact() throws InterruptedException{
        driver.get("http://m.baidu.com");
        driver.findElementByCssSelector("#index-kw").sendKeys("suzhou");
    }
    }
  • 相关阅读:
    获取txt文件的内容
    MAT(Memory Analyzer Tool)下载和安装
    转换流:指定编码 读取文本文件InputStreamReader和写出文本文件OutputStreamWriter 字符集
    切入点表达式
    并发时事务引发的问题和事务的隔离级别
    多线程之join方法
    多线程之守护线程
    约束:主键、非空、唯一、外键
    数据库设计
    PLSQL过期解决办法
  • 原文地址:https://www.cnblogs.com/tim2016/p/6054458.html
Copyright © 2020-2023  润新知