The uitest module

The Uitest class

uitest has it`s own APIs to let you get control to browsers

UT

The whole list of available uitest api is detailed below.

open(url,func)

url: String the url you wanna open

func: Function you can write all your test scripts inside this callback function

A function that can let you open browser or new windows

example:

UT.open("test.html", function(){
 //jasmine语句
  describe("打开页面test.html", function () {
       it("执行测试", function () {

       })
  })
})

go([url],func)

url: String optional the url you wanna go same as open

func: Function you can write all your test scripts inside this callback function

A function that let you go to a page , just as location.href,or just add another callback

example:

var win = UT.open("test.html", function(){
 //jasmine语句
  describe("打开页面test.html", function () {
       it("执行测试", function () {

       })
  })
})
win.go("test2.html", function () {
   //jasmine语句
  describe("跳转到页面test.html", function () {
       it("执行测试", function () {
       })
  })

})

ready(func)

func Function you can write all your test scripts inside this callback function

execute the function when the page is ready

example :

var win = UT.open("test.html", function(){
 //jasmine语句
  describe("打开页面test.html", function () {
       it("执行测试", function () {
          // 跳转
       })
  })
})
//等待页面加载完成
win.ready("test2.html", function () {
   //jasmine语句
  describe("跳转到页面test.html", function () {
       it("执行测试", function () {
       })
  })
})

setData(data)

set data by using setData to let the data cross pages

example:

UT.setData({
  username:"username",
  password:"password"
})

data : the data to set , so you can get the data on pages

getData(function(data){})

example:

UT.setData({
  username:"xiaoju4",
  password:"taobao1234"
})

UT.open("test.html", function () {
  describe("打开页面", function () {
       it("执行测试", function () {
          getData(function(data){console.log(data)})
       })
  })
})

config()

config(options)

options.autoClose

type : Boolean

default : true

when you set this to false , the opened window will not be closed, so you can do debug yourself on the page

example:

UT.config({autoClose:false})

options.timeout

type : Boolean

default : 60000 (sec)

the process of UT will exit if timeout

example:

UT.config({timeout:60000})

taobao

login(username,password,isDaily)

username String your username

password String your password,do not need to encode

isDaily Boolean if you set it to true , it mean you are in taobao develop env

you can use this to sign in taobao.com

Warning

you should use this before you use open

example:

//登录功能,写UT.open之前。
UT.taobao.login("xiaoju4","taobao1234",true);
UT.open("test2.html", function () {
   //jasmine语句
  describe("跳转到页面test.html", function () {
       it("执行测试", function () {
       })
  })
})

logout(isDaily)

isDaily Boolean if you set it to true , it mean you are in taobao develop env

you can use this to log out taobao.com

Warning

you should use this before you use open

example:

UT.taobao.logout(true)