// Type definitions for webdriverio 3.3.0 // Project: http://www.webdriver.io/ // Definitions by: Nick Malaguti // Definitions: https://github.com/borisyankov/DefinitelyTyped /// /// declare namespace WebdriverIO { // EventEmitter export interface Client { addListener(event: string, listener: Function): Client; on(event: string, listener: Function): Client; once(event: string, listener: Function): Client; removeListener(event: string, listener: Function): Client; removeAllListeners(event?: string): Client; setMaxListeners(n: number): Client; listeners(event: string): Client; emit(event: string, ...args: any[]): Client; } // Promise export interface Client { call(callback: () => any): Client; finally(callback: () => any): Client; then

(onFulfilled?: (value: T) => P | Client

, onRejected?: (err: any) => P | Client

): Client

; catch

(onRejected?: (err: any) => P | Client

): Client

; inspect(): Q.PromiseState; } // Action export interface Client { addValue(selector: string, value: string | number): Client; addValue

( selector: string, value: string | number, callback: (err: any) => P ): Client

; clearElement(selector: string): Client; clearElement

( selector: string, callback: (err: any) => P ): Client

; click(selector: string): Client; click

( selector: string, callback: (err: any) => P ): Client

; doubleClick(selector: string): Client; doubleClick

( selector: string, callback: (err: any) => P ): Client

; dragAndDrop(sourceElem: string, destinationElem: string): Client; dragAndDrop

( sourceElem: string, destinationElem: string, callback: (err: any) => P ): Client

; leftClick(selector: string): Client; leftClick

( selector: string, callback: (err: any) => P ): Client

; middleClick(selector: string): Client; middleClick

( selector: string, callback: (err: any) => P ): Client

; moveToObject(selector: string): Client; moveToObject(selector: string, xoffset: number, yoffset: number): Client; moveToObject

( selector: string, callback: (err: any) => P ): Client

; moveToObject

( selector: string, xoffset: number, yoffset: number, callback: (err: any) => P ): Client

; rightClick(selector: string): Client; rightClick

( selector: string, callback: (err: any) => P ): Client

; selectByIndex(selectElem: string, index: number): Client; selectByIndex

( selectElem: string, index: number, callback: (err: any) => P ): Client

; selectByValue(selectElem: string, value: string): Client; selectByValue

( selectElem: string, value: string, callback: (err: any) => P ): Client

; selectByVisibleText(selectElem: string, text: string): Client; selectByVisibleText

( selectElem: string, text: string, callback: (err: any) => P ): Client

; selectorExecute

( selectors: string | string[], script: (elements: HTMLElement | HTMLElement[], ...args: any[]) => P, ...args: any[] ): Client

; selectorExecuteAsync

( selectors: string | string[], script: (elements: HTMLElement | HTMLElement[], ...args: any[]) => P, ...args: any[] ): Client

; setValue(selector: string, values: number | string | Array): Client; setValue

( selector: string, values: number | string | Array, callback: (err: any) => P ): Client; submitForm(selector: string): Client; submitForm

( selector: string, callback: (err: any) => P ): Client; } // Appium export interface Client { // backgroundApp // closeApp // context // contexts // deviceKeyEvent // getAppStrings // getCurrentDeviceActivity // getNetworkConnection // hideDeviceKeyboard // installAppOnDevice // isAppInstalledOnDevice // launchApp // lock // openNotifications // performMultiAction // performTouchAction // pullFileFromDevice // pushFileToDevice // removeAppFromDevice // resetApp // rotate // setImmediateValueInApp // setNetworkConnection // shake // toggleAirplaneModeOnDevice // toggleDataOnDevice // toggleLocationServicesOnDevice // toggleWiFiOnDevice } export interface Cookie { name: string; value: string; } // Cookie export interface Client { deleteCookie(name?: string): Client; deleteCookie

( callback: (err: any) => P ): Client

; deleteCookie

( name: string, callback: (err: any) => P ): Client

; getCookie(): Client; getCookie(name: string): Client; getCookie

( callback: (err: any, cookies: Cookie[]) => P ): Client

; getCookie

( name: string, callback: (err: any, cookie: Cookie) => P ): Client

; setCookie(cookie: Cookie): Client; setCookie

( cookie: Cookie, callback: (err: any) => P ): Client

; } // Mobile export interface Client { // flick // flickDown // flickLeft // flickRight // flickUp // getGeoLocation // getOrientation // hold // release // setGeoLocation // setOrientation // touch } export interface CssProperty { property: string; value: string; parsed: ParsedCssProperty; } export interface ParsedCssProperty { type: string; string: string; quote: string; unit: string; value: string | number | string[] | number[]; } export interface Size { width: number; height: number; } export interface Location { x: number; y: number; } // Property export interface Client { getAttribute(selector: string, attributeName: string): Client; getAttribute

( selector: string, attributeName: string, callback: (err: any, attribute: string | string[]) => P ): Client

; getCssProperty(selector: string, cssProperty: string): Client; getCssProperty

( selector: string, cssProperty: string, callback: (err: any, cssProperty: CssProperty | CssProperty[]) => P ): Client

; getElementSize(selector: string): Client; getElementSize(selector: string, dimension: string): Client; getElementSize

( selector: string, callback: (err: any, size: Size | Size[]) => P ): Client

; getElementSize

( selector: string, dimension: string, callback: (err: any, elementSize: number | number[]) => P ): Client

; getHTML(selector: string, includeSelectorTag?: boolean): Client; getHTML

( selector: string, callback: (err: any, html: string | string[]) => P ): Client

; getHTML

( selector: string, includeSelectorTag: boolean, callback: (err: any, html: string | string[]) => P ): Client

; getLocation(selector: string): Client; getLocation(selector: string, axis: string): Client; getLocation

( selector: string, callback: (err: any, size: Size) => P ): Client

; getLocation

( selector: string, axis: string, callback: (err: any, location: number) => P ): Client

; getLocationInView(selector: string): Client; getLocationInView(selector: string, axis: string): Client; getLocationInView

( selector: string, callback: (err: any, size: Size | Size[]) => P ): Client

; getLocationInView

( selector: string, axis: string, callback: (err: any, location: number | number[]) => P ): Client

; getSource(): Client; getSource

(callback: (err: any, source: string) => P): Client

; getTagName(selector: string): Client; getTagName

( selector: string, callback: (err: any, tagName: string | string[]) => P ): Client

; getText(selector: string): Client; getText

( selector: string, callback: (err: any, text: string | string[]) => P ): Client

; getTitle(): Client; getTitle

( callback: (err: any, title: string) => P ): Client

; getUrl(): Client; getUrl

( callback: (err: any, title: string) => P ): Client

; getValue(selector: string): Client; getValue

( selector: string, callback: (err: any, value: string | string[]) => P ): Client

; } export interface LogEntry { timestamp: number; level: string; message: string; } export enum ApplicationCacheStatus { UNCACHED = 0, IDLE = 1, CHECKING = 2, DOWNLOADING = 3, UPDATE_READY = 4, OBSOLETE = 5 } export enum Button { left = 0, middle = 1, right = 2 } export interface StorageItem { key: string; value: any; } export interface Location { latitude: number; longitude: number; altitude: number; } export interface Session { id: string; capabilities: any; } export interface RawResult { value: T; } // Navigation export interface Client { back(): Client; back

( callback: (err: any) => P ): Client

; forward(): Client; forward

( callback: (err: any) => P ): Client

; refresh(): Client; refresh

( callback: (err: any) => P ): Client

; url(): Client>; url(url: string): Client; url

( callback: (err: any, result: RawResult) => P ): Client

; url

( url: string, callback: (err: any) => P ): Client

; } // Advanced input export interface Client { // you probably want to use the click and drag and drop commands instead buttonDown(button?: string | Button): Client; buttonDown

( callback: (err: any) => P ): Client

; buttonDown

( button: string | Button, callback: (err: any) => P ): Client

; // you probably want to use the click and drag and drop commands instead buttonPress(button?: string | Button): Client; buttonPress

( callback: (err: any) => P ): Client

; buttonPress

( button: string | Button, callback: (err: any) => P ): Client

; // you probably want to use the click and drag and drop commands instead buttonUp(button?: string | Button): Client; buttonUp

( callback: (err: any) => P ): Client

; buttonUp(button?: string | Button): Client; buttonUp

( button: string | Button, callback: (err: any) => P ): Client

; // you probably want to use the click and drag and drop commands instead doDoubleClick(): Client; doDoubleClick

( callback: (err: any) => P ): Client

; // you probably want to use addValue and setValue instead keys(value: string | string[]): Client; keys

( value: string | string[], callback: (err: any) => P ): Client

; // you probably want to use the moveToObject command instead moveTo(id: ElementId, xoffset?: number, yoffset?: number): Client; moveTo(xoffset?: number, yoffset?: number): Client; moveTo

( id: ElementId, callback: (err: any) => P ): Client

; moveTo

( id: ElementId, xoffset: number, callback: (err: any) => P ): Client

; moveTo

( id: ElementId, xoffset: number, yoffset: number, callback: (err: any) => P ): Client

; // touchClick // touchDoubleClick // touchDown // touchFlick // touchLongClick // touchMove // touchScroll // touchUp } // Useful Protocol export interface Client { alertAccept(): Client; alertAccept

( callback: (err: any) => P ): Client

; alertDismiss(): Client; alertDismiss

( callback: (err: any) => P ): Client

; alertText(text?: string): Client; alertText

( callback: (err: any, text: string) => P ): Client

; alertText

( text: string, callback: (err: any, text: string) => P ): Client

; frame(id: any): Client; frame

( id: any, callback: (err: any) => P ): Client

; frameParent(): Client; frameParent

( callback: (err: any) => P ): Client

; init(capabilities?: DesiredCapabilities): Client; init

( callback: (err: any) => P ): Client

; init

( capabilities: DesiredCapabilities, callback: (err: any) => P ): Client

; log(type: string): Client>; log

( type: string, callback: (err: any, result: RawResult) => P ): Client

; logTypes(): Client>; logTypes

( callback: (err: any, result: RawResult) => P ): Client

; session(action?: string, sessionId?: string): Client>; session

( callback: (err: any, result: RawResult) => P ): Client

; session

( action: string, callback: (err: any, result: RawResult) => P ): Client

; session

( action: string, sessionId: string, callback: (err: any, result: RawResult) => P ): Client

; sessions(): Client>; sessions

( callback: (err: any, sessions: RawResult) => P ): Client

; // timeouts // timeoutsAsyncScript // timeoutsImplicitWait // window // windowHandle // windowHandleMaximize // windowHandlePosition // windowHandleSize // windowHandles } export type ElementId = string; export interface Element { ELEMENT: ElementId; } // Element export interface Client { element(selector: string): Client>; element

( selector: string, callback: (err: any, result: RawResult) => P ): Client

; elementActive(): Client>; elementActive

( callback: (err: any, element: Element) => P ): Client

; elementIdAttribute(id: ElementId, attributeName: string): Client>; elementIdAttribute

( id: ElementId, attributeName: string, callback: (err: any, result: RawResult) => P ): Client

; elementIdClear(id: ElementId): Client; elementIdClear

( id: ElementId, callback: (err: any) => P ): Client

; elementIdClick(id: ElementId): Client; elementIdClick

( id: ElementId, callback: (err: any) => P ): Client

; elementIdCssProperty(id: ElementId, propertyName: string): Client>; elementIdCssProperty

( id: ElementId, propertyName: string, callback: (err: any, result: RawResult) => P ): Client

; elementIdDisplayed(id: ElementId): Client>; elementIdDisplayed

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdElement(id: ElementId, selector: string): Client>; elementIdElement

( id: ElementId, selector: string, callback: (err: any, result: RawResult) => P ): Client

; elementIdElements(id: ElementId, selector: string): Client>; elementIdElements

( id: ElementId, selector: string, callback: (err: any, result: RawResult) => P ): Client

; elementIdEnabled(id: ElementId): Client>; elementIdEnabled

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdLocation(id: ElementId): Client>; elementIdLocation

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdLocationInView(id: ElementId): Client>; elementIdLocationInView

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdName(id: ElementId): Client>; elementIdName

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdSelected(id: ElementId): Client>; elementIdSelected

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdSize(id: ElementId): Client>; elementIdSize

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdText(id: ElementId): Client>; elementIdText

( id: ElementId, callback: (err: any, result: RawResult) => P ): Client

; elementIdValue(id: ElementId, values: string | string[]): Client>; elementIdValue

( id: ElementId, values: string | string[], callback: (err: any, result: RawResult) => P ): Client

; elements(selector: string): Client>; elements

( selector: string, callback: (err: any, result: RawResult) => P ): Client

; } // Unuseful Protocol export interface Client { // applicationCacheStatus // cookie // use selectorExecute instead execute(script: string | Function, ...args: any[]): Client>; // use selectorExecuteAsync instead executeAsync(script: string | Function, ...args: any[]): Client>; // file // imeActivate // imeActivated // imeActiveEngine // imeAvailableEngines // imeDeactivated // localStorage // localStorageSize // location // orientation // screenshot // sessionStorage // sessionStorageSize // source // status // use submitForm instead submit(id: ElementId): Client; submit

( id: ElementId, callback: (err: any) => P ): Client

; // title } // State export interface Client { isEnabled(selector: string): Client; isEnabled

( selector: string, callback: (err: any, isEnabled: boolean) => P ): Client

; isExisting(selector: string): Client; isExisting

( selector: string, callback: (err: any, isExisting: boolean) => P ): Client

; isSelected(selector: string): Client; isSelected

( selector: string, callback: (err: any, isSelected: boolean) => P ): Client

; isVisible(selector: string): Client; isVisible

( selector: string, callback: (err: any, isVisible: boolean) => P ): Client

; isVisibleWithinViewport(selector: string): Client; isVisibleWithinViewport

( selector: string, callback: (err: any, isVisible: boolean) => P ): Client

; } export interface CommandHistoryEntry { command: string; args: any[]; } // Utility export interface Client { addCommand(commandName: string, customMethod: Function, overwrite?: boolean): Client; addCommand

( commandName: string, customMethod: Function, callback: (err: any) => P ): Client

; addCommand

( commandName: string, customMethod: Function, overwrite: boolean, callback: (err: any) => P ): Client

; chooseFile(selector: string, localPath: string): Client; chooseFile

( selector: string, localPath: string, callback: (err: any) => P ): Client

; debug(): Client; debug

( callback: (err: any) => P ): Client

; end(): Client; end

( callback: (err: any) => P ): Client

; endAll(): Client; endAll

( callback: (err: any) => P ): Client

; getCommandHistory(): Client; getCommandHistory

( callback: (err: any, history: CommandHistoryEntry[]) => P ): Client

; pause(milliseconds: number): Client; pause

(milliseconds: number, callback: (err: any) => P): Client

; saveScreenshot(filename?: string): Client; saveScreenshot

( callback: (err: any, screenshot: Buffer) => P ): Client

; saveScreenshot

( filename: string, callback: (err: any, screenshot: Buffer) => P ): Client

; scroll(selector: string): Client; scroll(selector: string, xoffset: number, yoffset: number): Client; scroll(xoffset: number, yoffset: number): Client; scroll

( selector: string, callback: (err: any) => P ): Client

; scroll

( selector: string, xoffset: number, yoffset: number, callback: (err: any) => P ): Client

; scroll

( xoffset: number, yoffset: number, callback: (err: any) => P ): Client

; uploadFile(localPath: string): Client; uploadFile

( localPath: string, callback: (err: any) => P ): Client

; waitForEnabled(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForEnabled

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForEnabled

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForEnabled

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitForExist(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForExist

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForExist

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForExist

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitForSelected(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForSelected

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForSelected

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForSelected

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitForText(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForText

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForText

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForText

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitForValue(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForValue

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForValue

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForValue

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitForVisible(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForVisible

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; waitForVisible

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; waitForVisible

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; waitUntil( condition: () => boolean | Q.IPromise, timeout?: number, interval?: number ): Client; waitUntil

( condition: () => boolean | Q.IPromise, callback: (err: any, enabled: boolean) => P ): Client

; waitUntil

( condition: () => boolean | Q.IPromise, timeout: number, callback: (err: any, enabled: boolean) => P ): Client

; waitUntil

( condition: () => boolean | Q.IPromise, timeout: number, interval: number, callback: (err: any, enabled: boolean) => P ): Client

; } // Window export interface Client { close(windowHandle?: string): Client; close

( callback: (err: any) => P ): Client

; close

( windowHandle: string, callback: (err: any) => P ): Client

; getCurrentTabId(): Client; getCurrentTabId

( callback: (err: any, tabId: string) => P ): Client

; getTabIds(): Client; getTabIds

( callback: (err: any, tabIds: string[]) => P ): Client

; getViewportSize(): Client; getViewportSize(dimension: string): Client; getViewportSize

( callback: (err: any, size: Size) => P ): Client

; getViewportSize

( dimension: string, callback: (err: any, viewportSize: number) => P ): Client

; newWindow(url: string, windowName: string, windowFeatures: string): Client; newWindow

( url: string, windowName: string, windowFeatures: string, callback: (err: any, windowId: string) => P ): Client

; setViewportSize(size: Size, type: boolean): Client; setViewportSize

( size: Size, type: boolean, callback: (err: any) => P ): Client

; switchTab(windowHandle?: string): Client; switchTab

( callback: (err: any) => P ): Client

; switchTab

( windowHandle: string, callback: (err: any) => P ): Client

; } export interface Options { protocol: string; waitforTimeout: number; coloredLogs: boolean; logLevel: string; baseUrl: string; desiredCapabilities: DesiredCapabilities; screenshotPath: string; } // Options export interface Client { options: Options; } export type DesiredCapabilities = any; export interface RemoteOptions { protocol?: string; waitforTimeout?: number; waitforInterval?: number; coloredLogs?: boolean; logLevel?: string; baseUrl?: string; desiredCapabilities?: DesiredCapabilities; } export interface MultiremoteOptions { [key: string]: RemoteOptions; } export function remote(options?: RemoteOptions | string): Client; export function multiremote(options?: MultiremoteOptions): Client; } declare var browser: WebdriverIO.Client; declare module "webdriverio" { export = WebdriverIO; }