【Appium对手机chrome浏览器操作】古人学问无遗力,少壮工夫老始成。这篇文章主要讲述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=" " ; br/>@Before
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 {br/>driver.quit();
}
@Test
driver.get(" http://m.baidu.com" );
driver.findElementByCssSelector(" #index-kw" ).sendKeys(" suzhou" );
}
}
推荐阅读
- Mybatis学习系列Mapper映射文件
- Android银行卡识别技术介绍与应用
- Flask_appbuilder的学习:安装
- AppleScript
- [Android] QPST,解BL锁,刷Recovery,备份系统,root,刷框架.
- mapper 动态代理 注意事项
- Android8.0适配那点事
- Android精通教程-第一节Android入门简介
- Android--记录莫名其妙的引用依赖冲突解决办法