# 跳一跳

业务流程:

  • 进入趣玩街,扫描游戏二维码,不断进行游戏

例子中展示:

  • 控制某段逻辑重复执行
import octopus from "jd-octopus"

describe("跳一跳用例", function () {

  var c = octopus("10.222.50.39:8080")
  var {device,info,img,text,point,swipe,sleep} = octopus()
  let uuids = ["ca829b6"]
  var err = ""

  it("获取控制设备", () => {
    device.bindDevices(uuids) // 绑定第一个设备
    sleep(1000)
  })


  it("自动运行跳一跳,自动捕捉结算页面", function () {
    img("./test/趣玩街/img/趣玩街.png").click()
    sleep(15000)
    text("取消").clickByOCR()
    sleep(3000)
    img("./test/趣玩街/img/我的.png").click()
    sleep(3000)
    img("./test/趣玩街/img/点击登录.png").click()
    sleep(3000)
    img("./test/趣玩街/img/允许.png").click()
    sleep(3000)
    img("./test/趣玩街/img/扫码游戏.png").click()
    sleep(3000)
    img("./test/趣玩街/img/相册.png").click()
    sleep(3000)
    point.clickByPercentage(0.65,0.15)
    sleep(3000)
    img("./test/趣玩街/img/进入游戏.png").click()
    sleep(3000)
    img("./test/趣玩街/img/允许.png").click()
    sleep(3000)
    img("./test/趣玩街/img/进入游戏.png").click()
    sleep(18000)
    text("准备").clickByOCR()
    sleep(20000)
    for (var x = 0; x < 240; x++) {
      point.clickByPercentage(0.5,0.5)
      sleep(300)
    }
    sleep(10000)

    try {
      img("./test/趣玩街/img/获得奖励.png").exists()
    } catch (error) {
      err += "奖励界面出错!"
    }

    sleep(2000)
    for (var y = 0; y < 100; y++) {
      text("再来一局").clickByOCR()
      sleep(10000)
      text("进入游戏").clickByOCR()
      sleep(15000)
      text("准备").clickByOCR()
      sleep(10000)
      for (var x = 0; x < 240; x++) {
        point.clickByPercentage(0.5,0.5)
        sleep(300)
      }
      sleep(10000)

      try {
        img("./test/趣玩街/img/获得奖励.png").exists()
      } catch (error) {
        err += "奖励界面出错!"
      }

      sleep(2000)
    }
    if (err != "") {
      throw new Error(err)
    }
  });

  it("退出趣玩街体验版", () => {
    device.runKeyCode(3)
    sleep(2000)
  })

});

Last Updated: 12/8/2020, 3:10:44 PM