51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 12042|回复: 7
打印 上一主题 下一主题

[求助] Monkeyrunner 循环出错 求指点

[复制链接]
  • TA的每日心情
    郁闷
    2016-11-23 12:02
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    跳转到指定楼层
    1#
    发表于 2016-11-24 15:14:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    5测试积点
    # coding:utf-8
    from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
    device=MonkeyRunner.waitForConnection(6,'emulator-5554')
    for i in range(1,10):
    device.startActivity(component="com.xs.cn/.activitys.LoadingActivity")
    MonkeyRunner.sleep(2)
    device.touch(280,470,"DOWN_AND_UP")
    MonkeyRunner.sleep(1)
    device.press('KEYCODE_BACK','DOWN_AND_UP')
    MonkeyRunner.sleep(1)
    device.touch(485,1072,"DOWN_AND_UP")
    print i
    else:
    print('end')
    在CMD执行后出现一大串,是哪里不对呢
    附件: 您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

    最佳答案

    查看完整内容

    # Imports the monkeyrunner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage # Connects to the current device, returning a MonkeyDevice object device = MonkeyRunner.waitForConnection() # Installs the Android package. Notice that this method returns a boolean, so you can test i=2 while i>0: device.touch(119,568,"DOWN_AND_UP") devic ...
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    该用户从未签到

    2#
    发表于 2016-11-24 15:14:39 | 只看该作者
    # Imports the monkeyrunner modules used by this program
    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
    # Connects to the current device, returning a MonkeyDevice object
    device = MonkeyRunner.waitForConnection()
    # Installs the Android package. Notice that this method returns a boolean, so you can test
    i=2
    while i>0:
      device.touch(119,568,"DOWN_AND_UP")
      device.shell("input text goup01")
      MonkeyRunner.sleep(8)
      i=i-1
      print(i)

    print("wancheng")


    这样你试下,应该是可以的,I是你循环的次数
    回复

    使用道具 举报

  • TA的每日心情

    2024-4-19 09:36
  • 签到天数: 942 天

    连续签到: 1 天

    [LV.10]测试总司令

    3#
    发表于 2016-11-25 11:08:51 | 只看该作者
    for i in range(次数):
    循环脚本
    ------------------------------------
    报错了一定是你脚本写错了

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 积极回复获得测试积点10

    查看全部评分

    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2017-1-23 16:40
  • 签到天数: 32 天

    连续签到: 1 天

    [LV.5]测试团长

    4#
    发表于 2016-11-25 11:26:21 | 只看该作者
    沙发
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2020-8-4 11:02
  • 签到天数: 943 天

    连续签到: 1 天

    [LV.10]测试总司令

    5#
    发表于 2016-11-25 18:06:14 | 只看该作者
    com.android.monkeyrunner import MonkeyRunner.MonkeyRunnerOptions IS yntaxError"mismatched  input 'device'" expecting

    INDENT",  ........   )

    从开始定义时,函数错误。
    回复

    使用道具 举报

  • TA的每日心情
    郁闷
    2016-11-23 12:02
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    6#
     楼主| 发表于 2016-11-26 17:36:43 | 只看该作者
    fhhh_eyou 发表于 2016-11-25 18:06
    com.android.monkeyrunner import MonkeyRunner.MonkeyRunnerOptions IS yntaxError"mismatched  input ' ...

    我去掉循环后,脚本是能够执行的,加上之后就不行了
    回复

    使用道具 举报

  • TA的每日心情
    郁闷
    2016-11-23 12:02
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    7#
     楼主| 发表于 2016-11-26 17:40:52 | 只看该作者
    梦想家 发表于 2016-11-25 11:08
    for i in range(次数):
    循环脚本
    ------------------------------------

    具体是哪里出错了呢
    回复

    使用道具 举报

    该用户从未签到

    8#
    发表于 2016-12-4 23:08:22 | 只看该作者
    注意对齐, 缩进, 都用空格, 别TAB. 提示是语法错误了.
    回复

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-4-27 10:44 , Processed in 0.073507 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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