• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 使用 MonkeyRunner 進行自動化測試(3)

    發表于:2017-07-24來源:簡書作者: 白帽子耗子點擊數: 標簽:MonkeyRunner
    ,time.localtime(time.time())) #獲取日期 def getToday () : return time.strftime( %Y_%m_%d ,time.localtime(time.time())) #截圖并保存 def shotPhoto () : newimage = device.takeSnapshot() newimage
    ,time.localtime(time.time())) #獲取日期 def getToday(): return time.strftime("%Y_%m_%d",time.localtime(time.time())) #截圖并保存 def shotPhoto(): newimage = device.takeSnapshot() newimage.writeToFile ("ImageFile/" + getToday() + getNowTimeUnderline() + ".png" , "png") time.sleep(1.0) #創建存儲截圖的文件夾 def mkdirPath(path): if not os.path.exists(path): os.mkdir(path) #創建文件夾 mkdirPath("ImageFile") #啟動應用 device.startActivity(component = mRunComponent) time.sleep(3.0)#啟動Acticity的時間 for slipCount in range(1,3):#迭代1到3之間,相當于循環兩次。 device.drag( (385,1032), (385,700), 1.0, 10 )#向上滑動 time.sleep(2.0) shotPhoto() device.touch(399, 73, "DOWN_AND_UP")#單擊該坐標(網址輸入欄) time.sleep(1.0) shotPhoto() device.type('https://shlurenjia.github.io')#鍵盤輸入網址,這是我的博客 time.sleep(1.0) device.press('KEYCODE_ENTER', MonkeyDevice.DOWN_AND_UP)#enter 確認跳轉 time.sleep(5.0) shotPhoto() device.touch(325, 357, "DOWN_AND_UP")#點擊第一篇文章 time.sleep(1.0) shotPhoto() device.press('KEYCODE_BACK','DOWN_AND_UP') #第二個參數也可以這樣簡寫 time.sleep(2.0) shotPhoto() device.press('KEYCODE_BACK','DOWN_AND_UP') time.sleep(2.0) shotPhoto()

    截圖可以讓你掛完腳本之后自己比對效果。每個動作后面加上 sleep 因為要考慮到手機響應的時間。不然腳本執行下去很容易報錯 Error sending xxx event

    效果

    由于加了sleep,所以看起來比較慢


    自動化測試.gif

    ?



    作者:白帽子耗子
    鏈接:http://www.jianshu.com/p/93401c23451a
    來源:簡書
    著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。

    原文轉自:http://www.jianshu.com/p/93401c23451a

    ...

    熱門標簽

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>