API Docs for: 2.2.0
Show:

Browser Class

Defined in: lib/browser.js:2

This class is used for control browser.

Methods

acceptAlert

(
  • done
)
public

Defined in lib/browser.js:1075

accept alert or confirm

Parameters:

  • done Function

    callback function

back

(
  • done
)
public

Defined in lib/browser.js:778

back the window

Parameters:

  • done Function

    callback function

clearCookies

(
  • done
)
public

Defined in lib/browser.js:920

clear all cookies

Parameters:

  • done Function

    callback function

clearLocalStorages

(
  • done
)
public

Defined in lib/browser.js:986

clear all local storage

Parameters:

  • done Function

    callback function

clearSessionStorages

(
  • done
)
public

Defined in lib/browser.js:1052

clear all session storage

Parameters:

  • done Function

    callback function

click

(
  • [key]
  • done
)
public

Defined in lib/browser.js:1269

send click

Parameters:

  • [key] String optional
  • done Function

    callback function

close

(
  • done
)
public

Defined in lib/browser.js:1806

close session

Parameters:

  • done Function

    callback function

closeWindow

(
  • done
)
public

Defined in lib/browser.js:601

close current window

Parameters:

  • done Function

    callback function

config

(
  • options
  • done
)
public

Defined in lib/browser.js:308

config webdriver options

Parameters:

  • options String

    options for webdriver config

  • done Function

    callback function

constructor

(
  • driver
  • browserName
  • version
  • platform
  • done
)
private

Defined in lib/browser.js:133

init browser instance

Parameters:

  • driver JWebDriver

    JWebDriver instance

  • browserName String | Object

    or capabilitie object

  • version String
  • platform String
  • done Function

    callback function

context

(
  • [contextId]
  • done
)
public

Defined in lib/browser.js:1838

get or set context

Parameters:

  • [contextId] String optional

    context id

  • done Function

    callback function

contexts

(
  • done
)

Defined in lib/browser.js:1827

get contexts

Parameters:

  • done Function

    callback function

cookies

(
  • isArray
  • done
)
Array public

Defined in lib/browser.js:798

get all cookies

Parameters:

  • isArray Boolean
  • done Function

    callback function

Returns:

Array:

return all cookies

dblClick

(
  • done
)
public

Defined in lib/browser.js:1292

send double Click

Parameters:

  • done Function

    callback function

dismissAlert

(
  • done
)
public

Defined in lib/browser.js:1085

dismiss confirm

Parameters:

  • done Function

    callback function

doubleClick

(
  • done
)
public

Defined in lib/browser.js:1302

send double Click

Parameters:

  • done Function

    callback function

dragDrop

(
  • from
  • to
  • done
)
public

Defined in lib/browser.js:1312

drag one element to another

Parameters:

eval

(
  • script
  • [args]
  • done
)
Any public

Defined in lib/browser.js:431

execute script in browser

Parameters:

  • script String | Function

    function to eval

  • [args] Array optional

    arguments send to script

  • done Function

    callback function

Returns:

Any:

js function returned value

exec

(
  • script
  • [args]
  • done
)
Any public

Defined in lib/browser.js:381

execute script in browser

Parameters:

  • script String | Function

    function to exec

  • [args] Array optional

    arguments send to script

  • done Function

    callback function

Returns:

Any:

js function returned value

execCmd

(
  • cmd
  • [pathData]
  • [data]
  • done
)
Object public

Defined in lib/browser.js:249

execute protocal command with this session

Parameters:

  • cmd String

    protocal command, defined in command.js

  • [pathData] Object optional

    replace the path parameters, no need to add sessionId

  • [data] Object optional

    send data to protocal api

  • done Function

    callback function

Returns:

Object:

the return object from webdriver server

find

(
  • [using]
  • value
  • done
)
Elments public

Defined in lib/browser.js:1343

find element

Parameters:

  • [using] String optional

    find mode: class name|css selector|id|name|link text|partial link text|tag name|xpath

  • value String

    find pattern

  • done Function

    callback function

Returns:

Elments:

findVisible

(
  • [using]
  • value
  • done
)
Elments public

Defined in lib/browser.js:1363

find visible element

Parameters:

  • [using] String optional

    find mode: class name|css selector|id|name|link text|partial link text|tag name|xpath

  • value String

    find pattern

  • done Function

    callback function

Returns:

Elments:

forward

(
  • done
)
public

Defined in lib/browser.js:788

forward the window

Parameters:

  • done Function

    callback function

frames

(
  • done
)
Element public

Defined in lib/browser.js:550

get all frame elements

Parameters:

  • done Function

    callback function

Returns:

Element:

geolocation

(
  • [latitude]
  • [longitude]
  • [altitude]
  • done
)
Object public

Defined in lib/browser.js:1767

get or set geolocation

Parameters:

  • [latitude] Number | Object optional

    latitude

  • [longitude] Number optional

    longitude

  • [altitude] Number optional

    altitude

  • done Function

    callback function

Returns:

Object:

return {latitude:1, longitude:1, altitude:1}

getAlert

(
  • done
)
String public

Defined in lib/browser.js:1062

get alert text

Parameters:

  • done Function

    callback function

Returns:

String:

getScreenshot

(
  • [filename]
  • done
)
String public

Defined in lib/browser.js:707

get screenshot

Parameters:

  • [filename] String optional

    save screenshot to file

  • done Function

    callback function

Returns:

String:

return screenshot by base64 format

html

(
  • done
)
String public

Defined in lib/browser.js:755

nick name of source

Parameters:

  • done Function

    callback function

Returns:

String:

return document html

info

() Object public

Defined in lib/browser.js:274

get browser info

Returns:

Object:

info object

init

(
  • done
)
private

Defined in lib/browser.js:151

init browser

Parameters:

  • done Function

    callback function

isStickyKey

(
  • key
)
Boolean public

Defined in lib/browser.js:1127

check sticky key

Parameters:

  • key String

Returns:

Boolean:

keyDown

(
  • key
  • done
)
public

Defined in lib/browser.js:1139

send keydown

Parameters:

  • key String
  • done Function

    callback function

keyUp

(
  • key
  • done
)
public

Defined in lib/browser.js:1158

send keyup

Parameters:

  • key String
  • done Function

    callback function

localStorage

(
  • name
  • [value]
  • done
)
String public

Defined in lib/browser.js:943

get or set local storage

Parameters:

  • name String

    local storage name

  • [value] String optional

    local storage value

  • done Function

    callback function

Returns:

String:

return local storage value or this

localStorageKeys

(
  • done
)
Array public

Defined in lib/browser.js:930

get all local storage keys

Parameters:

  • done Function

    callback function

Returns:

Array:

return all local storage keys

log

(
  • type
  • message
)
public

Defined in lib/browser.js:238

save log

Parameters:

  • type COMMAND | DATA | RESULT | ERROR | WARNING | INFO

    log type

  • message Object

    log message

maximize

(
  • done
)
public

Defined in lib/browser.js:691

maximize the window

Parameters:

  • done Function

    callback function

mouseDown

(
  • [key]
  • done
)
public

Defined in lib/browser.js:1223

send mousedown

Parameters:

  • [key] String optional
  • done Function

    callback function

mouseMove

(
  • elements
  • [x]
  • [y]
  • done
)
public

Defined in lib/browser.js:1177

send mousemove (first element)

Parameters:

  • elements Elements | String
  • [x] Number | Object optional
  • [y] Number optional
  • done Function

    callback function

mouseUp

(
  • [key]
  • done
)
public

Defined in lib/browser.js:1246

send mouseup

Parameters:

  • [key] String optional
  • done Function

    callback function

native

(
  • done
)

Defined in lib/browser.js:1861

set context to native

Parameters:

  • done Function

    callback function

newWindow

(
  • windowHandle
  • done
)
String public

Defined in lib/browser.js:524

open new window

Parameters:

  • windowHandle String

    window handle

  • done Function

    callback function

Returns:

String:

return window handle

orientation

(
  • [orientation]
  • done
)
Object | This public

Defined in lib/browser.js:1739

get or set orientation

Parameters:

  • [orientation] String optional

    orientation

  • done Function

    callback function

Returns:

Object | This:

return {x:1,y:1} or this

position

(
  • [x]
  • [x]
  • done
)
Object | This public

Defined in lib/browser.js:611

get or set position of window

Parameters:

  • [x] Number | Object optional

    x position

  • [x] Number | Object optional

    x position

  • done Function

    callback function

Returns:

Object | This:

return {x:1,y:1} or this

refresh

(
  • done
)
public

Defined in lib/browser.js:768

refresh the window

Parameters:

  • done Function

    callback function

removeCookie

(
  • name
  • done
)
public

Defined in lib/browser.js:907

remove cookie

Parameters:

  • name String

    cookie name

  • done Function

    callback function

removeLocalStorage

(
  • name
  • done
)
public

Defined in lib/browser.js:973

remove local storage

Parameters:

  • name String

    local storage name

  • done Function

    callback function

removeSessionStorage

(
  • name
  • done
)
public

Defined in lib/browser.js:1039

remove session storage

Parameters:

  • name String

    session storage name

  • done Function

    callback function

scrollTo

(
  • [elements]
  • [x]
  • [y]
  • done
)
public

Defined in lib/browser.js:1508

scroll to

Parameters:

  • [elements] Elements | String optional
  • [x] Number optional
  • [y] Number optional
  • done Function

    callback function

sendActions

(
  • type
  • params
  • done
)
public

Defined in lib/browser.js:1883

send actions

Parameters:

  • type String
  • params Object
  • done Function

    callback function

sendKeys

(
  • text
  • done
)
public

Defined in lib/browser.js:1108

send keys to browser

Parameters:

  • text String
  • done Function

    callback function

sessionStorage

(
  • name
  • [value]
  • done
)
String public

Defined in lib/browser.js:1009

get or set session storage

Parameters:

  • name String

    session storage name

  • [value] String optional

    session storage value

  • done Function

    callback function

Returns:

String:

return session storage value or this

sessionStorageKeys

(
  • done
)
Array public

Defined in lib/browser.js:996

get all session storage keys

Parameters:

  • done Function

    callback function

Returns:

Array:

return all session storage keys

setAlert

(
  • text
  • done
)
public

Defined in lib/browser.js:1095

set text to prompt

Parameters:

  • text String
  • done Function

    callback function

size

(
  • [width]
  • [height]
  • done
)
Object | This public

Defined in lib/browser.js:651

get or set size of window

Parameters:

  • [width] Number | Object optional
  • [height] Number | Object optional
  • done Function

    callback function

Returns:

Object | This:

return {width:1,height:1} or this

sleep

(
  • ms
  • done
)
public

Defined in lib/browser.js:297

sleep sync

Parameters:

  • ms Number

    millisecond

  • done Function

    callback function

source

(
  • done
)
String public

Defined in lib/browser.js:742

get source

Parameters:

  • done Function

    callback function

Returns:

String:

return source

support

(
  • capability
)
Object public

Defined in lib/browser.js:284

get capability support

Parameters:

  • capability String

Returns:

Object:

info object

switchFrame

(
  • frame
  • done
)
public

Defined in lib/browser.js:561

switch to frame or main page

Parameters:

  • frame Elements | String
  • done Function

    callback function

switchFrameParent

(
  • done
)
public

Defined in lib/browser.js:591

switch to parent frame

Parameters:

  • done Function

    callback function

switchWindow

(
  • windowHandle
  • done
)
public

Defined in lib/browser.js:490

switch to window

Parameters:

  • windowHandle String

    window handle

  • done Function

    callback function

title

(
  • done
)
String public

Defined in lib/browser.js:729

get title

Parameters:

  • done Function

    callback function

Returns:

String:

return document title

touchDown

(
  • x
  • y
  • done
)
public

Defined in lib/browser.js:1599

touch down

Parameters:

  • x Number
  • y Number
  • done Function

    callback function

touchFlick

(
  • xspeed
  • yspeed
  • done
)
public

Defined in lib/browser.js:1711

touch flick

Parameters:

  • xspeed Number
  • yspeed Number
  • done Function

    callback function

touchMove

(
  • x
  • y
  • done
)
public

Defined in lib/browser.js:1627

touch move

Parameters:

  • x Number
  • y Number
  • done Function

    callback function

touchScroll

(
  • x
  • y
  • done
)
public

Defined in lib/browser.js:1683

touch scroll

Parameters:

  • x Number
  • y Number
  • done Function

    callback function

touchUp

(
  • x
  • y
  • done
)
public

Defined in lib/browser.js:1655

touch up

Parameters:

  • x Number
  • y Number
  • done Function

    callback function

uploadFileToServer

(
  • localPath
  • done
)
String public

Defined in lib/browser.js:1573

upload file to browser machine

Parameters:

  • localPath String
  • done Function

    callback function

Returns:

String:

webdriver server filepath

url

(
  • [url]
  • done
)
Url | This public

Defined in lib/browser.js:353

goto url or get url

Parameters:

  • [url] String optional

    url for goto

  • done Function

    callback function

Returns:

Url | This:

return this or url

wait

(
  • [using]
  • value
  • [options]
  • done
)
Elments public

Defined in lib/browser.js:1426

wait for element displayed or removed

Parameters:

  • [using] String optional

    find mode: class name|css selector|id|name|link text|partial link text|tag name|xpath

  • value String

    find pattern

  • [options] String optional
  • done Function

    callback function

Returns:

Elments:

webview

(
  • done
)

Defined in lib/browser.js:1872

set context to webview

Parameters:

  • done Function

    callback function

windowHandle

(
  • useCache
  • done
)
String public

Defined in lib/browser.js:445

get current window handle

Parameters:

  • useCache Boolean
  • done Function

    callback function

Returns:

String:

window handle

windowHandles

(
  • done
)
Array public

Defined in lib/browser.js:477

get all window handles

Parameters:

  • done Function

    callback function

Returns:

Array:

window handle

Properties

Keys

Unknown public

Defined in lib/browser.js:126

keyboard buttons

MouseButtons

Unknown public

Defined in lib/browser.js:119

mouse buttons