51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1588|回复: 0
打印 上一主题 下一主题

appium拖放元素

[复制链接]
  • TA的每日心情
    擦汗
    昨天 09:53
  • 签到天数: 433 天

    连续签到: 2 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2018-12-25 16:05:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    拖放元素的解决方法如下,是开源中国APP增加栏目后,再比较增加栏目名称是否成功的实例:
    1. //移动元素,再比较
    2.                 MobileElement layoutView = (MobileElement)driver.findElement(By
    3.             .id("net.oschina.app:id/layout_tab"));
    4.                 List<MobileElement> support = layoutView.findElements(By
    5.             .className("android.widget.TextView"));
    6.                      MobileElement supportText1=support.get(0);
    7.                      MobileElement supportText4=support.get(3);
    8.                      MobileElement supportTextLast=support.get(support.size()-1);
    9.                 TouchAction touchAction = new TouchAction(driver);
    10.                 touchAction.press(supportText4).perform();
    11.                 try {
    12.                     Thread.sleep(5000);
    13.                 } catch (InterruptedException e) {
    14.                     e.printStackTrace();
    15.                 }
    16.                 touchAction.moveTo(supportText1).release().perform();
    17.                 Thread.sleep(5000);
    18.                 Assert.assertEquals(supportTextLast.getText(),addColumnText);
    复制代码


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-6-19 08:52 , Processed in 0.065935 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表