还是去看 appium sample code 吧
public class AndroidContactsTest {
private AppiumDriver driver;
@BeforeMethod
public void setUp() throws Exception {
// set up appium
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
cap.setCapability("platformName", "Android");
cap.setCapability("deviceName", "HC37PW902955");
cap.setCapability("platformVersion", "4.4");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap); }
@AfterMethod
public void tearDown() throws Exception {
driver.quit();}
@Test
public void addContact(){
//找输入框并点击
//WebElement text = driver.findElementByClassName("android.widget.EditText");
//text.sendKeys("www.baidu.com");
driver.get("http://www.baidu.com");
}
}
你装个豌豆荚,看看能用不么?要么你把开发者选项打开啊
@seasoncool2011 这是我被折磨了 2 天的成果啊:)
我想你说的是类似于微信中的按住说话吧
action1 = TouchAction(self.driver)
el = self.driver.find_element_by_id('XXXXX1')
action1.long_press(el).wait(10000).perform()
action2 = TouchAction(self.driver)
el = self.driver.find_element_by_id('XXXXX2')
action2.moveTo(el).release().perform()
@sundaxian 测试通过了,谢谢
不过还要在一下代码添加
1)class 要添加 static
2) 添加这个构造函数 public SwipeableWebDriver(){ }
public static class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
private RemoteTouchScreen touch;
public SwipeableWebDriver(){
}
public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
touch = new RemoteTouchScreen(getExecuteMethod());
}
public TouchScreen getTouch() {
return touch;
}
}
@sundaxian 什么问题,求解啊