首页 > 移动平台 > 详细

使用AppleScript进行简单的自动化测试(四)

时间:2014-02-21 00:11:38      阅读:544      评论:0      收藏:0      [点我收藏+]

  AppleScript的实际应用

 

  1.连接网络:在做自动化测试有时需要从服务器上下载build,那么我们需要连接网络  

mount volume "smb://xx.xx.xx.xx/xx/xx" as user name "userName" with password "password"

  连接成功后,会在xx‘s Mac 下看到映射的地址.

 

  2.launch 程序:

    1>dmg:    

tell application "Finder"
  open document file "System:Users:zzz:Desktop:xx.dmg"

    2>app:

launch application "System:Users:zzz:Desktop:Accessibility Inspector.app"

 

  3.打开URL:进入百度首页

open location "http://www.baidu.com"

   

  4.获取第一个窗体的process name  

set frontApp to name of first application process whose frontmost is true

  

  5.获取所有可见app的process name 

set visibleApps to application process whose visible is true

 

  6.获取随机数

random number from 1 to 4

 

  7.时间

bubuko.com,布布扣
tell application "System Events"
    set tmpDate to (current date)
  
    get seconds of tmpDate  --秒

    get minutes of tmpDate  --分

             get hours of tmpDate     --时

    get day of tmpDate         --天

    get month of tmpDate     --月

    get year of tmpDate        --年

    time string of tmpDate     --当前时间:4:58:09 PM

    date string of tmpDate     --Wednesday, February 19, 2014
    
   实现datediff功能(返回second)
    set StartTime to current date
    delay 2
    get (current date) - StartTime
end tell        
bubuko.com,布布扣

 

  8.字符串:

    Split方法    

on Split(delimiter, splitString)
    tell application "System Events"
        set AppleScripts text item delimiters to delimiter
        set aa to every text item of splitString
    end tell
end Split

 

    Replace方法    

bubuko.com,布布扣
on Replace(repalceString, oldString, newString)
    tell application "System Events"
        set AppleScripts text item delimiters to oldString
        set aa to every text item of repalceString
        set AppleScripts text item delimiters to newString
        set bb to aa as string
    end tell
end Replace
bubuko.com,布布扣

 

 

 

 

使用AppleScript进行简单的自动化测试(四)

原文:http://www.cnblogs.com/Alvin-x/p/3555982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!