diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index 44a0e6ea57..fbc6925fa9 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webdriverio 4.0.4 +// Type definitions for webdriverio 4.4.0 // Project: http://www.webdriver.io/ // Definitions by: Nick Malaguti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -30,96 +30,118 @@ declare namespace WebdriverIO { // Action export interface Client { - addValue(selector: string, value: string | number): Client; + addValue( + selector: string, + value: string | number + ): Client; + addValue(value: string | number): Client; addValue

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

; + addValue

(value: string | number): Client

; - clearElement(selector: string): Client; - clearElement

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

; + clearElement(selector?: string): Client; + clearElement

(selector?: string): Client

; - click(selector: string): Client; - click

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

; + click(selector?: string): Client; + click

(selector?: string): Client

; - doubleClick(selector: string): Client; - doubleClick

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

; + doubleClick(selector?: string): Client; + doubleClick

(selector?: string): Client

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

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

; + dragAndDrop

(destinationElem: string): Client

; - leftClick(selector: string): Client; - leftClick

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

; + leftClick(selector?: string): Client; + leftClick

(selector?: string): Client

; - middleClick(selector: string): Client; - middleClick

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

; + middleClick(selector?: string): Client; + middleClick

(selector?: string): Client

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

( + moveToObject(selector?: string): Client; + moveToObject( selector: string, - callback: (err: any) => P - ): Client

; + xoffset: number, + yoffset: number + ): Client; + moveToObject( + xoffset: number, + yoffset: number + ): Client; + moveToObject

(selector?: string): Client

; moveToObject

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

; + moveToObject

( + xoffset: number, + yoffset: number ): Client

; - rightClick(selector: string): Client; - rightClick

( + rightClick(selector?: string): Client; + rightClick

(selector?: string): Client

; + + selectByAttribute( selector: string, - callback: (err: any) => P - ): Client

; - - selectByAttribute(selector: string, attribute: string, value: string): Client; + attribute: string, + value: string + ): Client; + selectByAttribute( + attribute: string, + value: string + ): Client; selectByAttribute

( selector: string, attribute: string, - value: string, - callback: (err: any) => P + value: string + ): Client

; + selectByAttribute

( + attribute: string, + value: string ): Client

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

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

; + selectByIndex

(index: number): Client

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

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

; + selectByValue

(value: string): Client

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

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

; + selectByVisibleText

(text: string): Client

; selectorExecute

( selectors: string | string[], @@ -133,18 +155,23 @@ declare namespace WebdriverIO { ...args: any[] ): Client

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

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

( + values: number | string | Array ): Client; - submitForm(selector: string): Client; - submitForm

( - selector: string, - callback: (err: any) => P - ): Client; + submitForm(selector?: string): Client; + submitForm

(selector?: string): Client

; } // Appium @@ -187,51 +214,31 @@ declare namespace WebdriverIO { // Cookie export interface Client { deleteCookie(name?: string): Client; - deleteCookie

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

; - deleteCookie

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

; + deleteCookie

(name?: string): 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

; + getCookie

(name?: string): Client

; setCookie(cookie: Cookie): Client; - setCookie

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

; + setCookie

(cookie: Cookie): Client

; } export interface Client { - session(action?: string, sessionId?: string): Client>; - session

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

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

(): Client

; getGridNodeDetails(): Client; - getGridNodeDetails

( - callback: (err: any, details: Object) => P - ): Client

; + getGridNodeDetails

(): Client

; gridProxyDetails(): Client; - gridProxyDetails

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

; + gridProxyDetails

(): Client

; gridTestSession(): Client; - gridProxyDetails

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

; + gridProxyDetails

(): Client

; } // Mobile @@ -276,97 +283,123 @@ declare namespace WebdriverIO { // Property export interface Client { - getAttribute(selector: string, attributeName: string): Client; + getAttribute( + selector: string, + attributeName: string + ): Client & string; + getAttribute( + selector: string, + attributeName: string + ): Client & string[]; + getAttribute(attributeName: string): Client & string; + getAttribute(attributeName: string): Client & string[]; getAttribute

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

; + getAttribute

(attributeName: string): Client

; - getCssProperty(selector: string, cssProperty: string): Client; + getCssProperty( + selector: string, + cssProperty: string + ): CssProperty; + getCssProperty( + selector: string, + cssProperty: string + ): CssProperty[]; + getCssProperty(cssProperty: string): CssProperty; + getCssProperty(cssProperty: string): CssProperty[]; getCssProperty

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

; + getCssProperty

(cssProperty: string): Client

; - getElementSize(selector: string): Client; - getElementSize(selector: string, dimension: string): Client; + getElementSize(selector: string): Client & Size; + getElementSize(selector: string): Client & Size[]; + getElementSize(): Client & Size|Size[]; + getElementSize( + selector: string, + dimension: string + ): number; + getElementSize( + selector: string, + dimension: string + ): number[]; + getElementSize(dimension: string): number ; + getElementSize(dimension: string): number[]; + getElementSize

(selector?: 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 + dimension: string ): Client

; + getElementSize

(dimension: string): Client

; - getHTML(selector: string, includeSelectorTag?: boolean): Client; + getHTML( + selector: string, + includeSelectorTag?: boolean + ): string; + getHTML( + selector: string, + includeSelectorTag?: boolean + ): string[]; + getHTML(includeSelectorTag?: boolean): string; + getHTML(includeSelectorTag?: boolean): string[]; + getHTML

(selector?: string): Client

; getHTML

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

; - getHTML

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

; + getHTML

(includeSelectorTag: boolean): Client

; - getLocation(selector: string): Client; - getLocation(selector: string, axis: string): Client; + getLocation(selector?: string): Size; + getLocation(selector: string, axis: string): number; + getLocation(axis: string): number; + getLocation

(selector?: string): Client

; getLocation

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

; - getLocation

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

; + getLocation

(axis: string): Client

; - getLocationInView(selector: string): Client; - getLocationInView(selector: string, axis: string): Client; + getLocationInView(selector: string): Size; + getLocationInView(selector: string): Size[]; + getLocationInView(): Size; + getLocationInView(): Size[]; + getLocationInView( + selector: string, + axis: string + ): number; + getLocationInView( + selector: string, + axis: string + ): number[]; + getLocationInView(axis: string): number; + getLocationInView(axis: string): number[]; + getLocationInView

(selector?: string): Client

; getLocationInView

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

; - getLocationInView

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

; + getLocationInView

(axis: string): Client

; getSource(): Client; - getSource

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

; + getSource

(): Client

; - getTagName(selector: string): Client; - getTagName

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

; + getTagName(selector?: string): string | string[]; + getTagName

(selector?: string): Client

; - getText(selector: string): Client; - getText

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

; + getText(selector?: string): string | string[]; + getText

(selector?: string): Client

; getTitle(): Client; - getTitle

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

; + getTitle

(): Client

; getUrl(): Client; - getUrl

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

; + getUrl

(): Client

; - getValue(selector: string): Client; - getValue

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

; + getValue(selector?: string): string | string[]; + getValue

(selector?: string): Client

; } export interface LogEntry { @@ -395,7 +428,7 @@ declare namespace WebdriverIO { value: any; } - export interface GeoLocation { + export interface Location { latitude: number; longitude: number; altitude: number; @@ -413,94 +446,56 @@ declare namespace WebdriverIO { // Navigation export interface Client { back(): Client; - back

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

; + back

(): Client

; forward(): Client; - forward

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

; + forward

(): Client

; refresh(): Client; - refresh

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

; + refresh

(): Client

; - url(): Client>; + url(): Client> & RawResult; url(url: string): Client; - url

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

; - url

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

; + url

(url?: string): 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

; + buttonDown

(button?: string | Button): 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

; + buttonPress

(button?: string | Button): 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

; + buttonUp

(button?: string | Button): Client

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

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

; + doDoubleClick

(): Client

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

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

; + keys

(value: string | string[]): 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

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

; + xoffset?: number, + yoffset?: number + ): Client; + moveTo( + xoffset?: number, + yoffset?: number + ): Client; + moveTo

(id: ElementId): Client

; moveTo

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

; - moveTo

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

; // touchClick @@ -516,73 +511,42 @@ declare namespace WebdriverIO { // Useful Protocol export interface Client { alertAccept(): Client; - alertAccept

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

; + alertAccept

(): Client

; alertDismiss(): Client; - alertDismiss

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

; + alertDismiss

(): Client

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

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

; - alertText

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

; + alertText

(): Client

; + alertText

(text: string): Client

; frame(id: any): Client; - frame

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

; + frame

(id: any): Client

; frameParent(): Client; - frameParent

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

; + frameParent

(): Client

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

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

; - init

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

; + init

(capabilities?: DesiredCapabilities): Client

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

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

; + log

(type: string): Client

; - logTypes(): Client>; - logTypes

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

; + logTypes(): Client> & RawResult; + logTypes

(): Client

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

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

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

(action?: string): Client

; session

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

; - session

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

; sessions(): Client>; - sessions

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

; + sessions

(): Client

; // timeouts // timeoutsAsyncScript @@ -604,117 +568,89 @@ declare namespace WebdriverIO { // Element export interface Client { - element(selector: string): Client>; - element

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

; + element(selector: string): Client> & RawResult; + element

(selector: string): Client

; - elementActive(): Client>; - elementActive

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

; + elementActive(): Client> & RawResult; + elementActive

(): Client

; - elementIdAttribute(id: ElementId, attributeName: string): Client>; + elementIdAttribute( + id: ElementId, + attributeName: string + ): Client> & RawResult; elementIdAttribute

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

; elementIdClear(id: ElementId): Client; - elementIdClear

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

; + elementIdClear

(id: ElementId): Client

; elementIdClick(id: ElementId): Client; - elementIdClick

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

; + elementIdClick

(id: ElementId): Client

; - elementIdCssProperty(id: ElementId, propertyName: string): Client>; + elementIdCssProperty( + id: ElementId, + propertyName: string + ): Client> & RawResult; elementIdCssProperty

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

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

( + elementIdDisplayed(id: ElementId): Client> & RawResult; + elementIdDisplayed

(id: ElementId): Client

; + + elementIdElement( id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; - - elementIdElement(id: ElementId, selector: string): Client>; + selector: string + ): Client> & RawResult; elementIdElement

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

; - elementIdElements(id: ElementId, selector: string): Client>; + elementIdElements( + id: ElementId, + selector: string + ): Client> & RawResult; elementIdElements

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

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

( + elementIdEnabled(id: ElementId): Client> & RawResult; + elementIdEnabled

(id: ElementId): Client

; + + elementIdLocation(id: ElementId): Client> & RawResult; + elementIdLocation

(id: ElementId): Client

; + + elementIdLocationInView(id: ElementId): Client> & RawResult; + elementIdLocationInView

(id: ElementId): Client

; + + elementIdName(id: ElementId): RawResult; + elementIdName

(id: ElementId): Client

; + + elementIdSelected(id: ElementId): Client> & RawResult; + elementIdSelected

(id: ElementId): Client

; + + elementIdSize(id: ElementId): Client> & RawResult; + elementIdSize

(id: ElementId): Client

; + + elementIdText(id: ElementId): Client> & RawResult; + elementIdText

(id: ElementId): Client

; + + elementIdValue( 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>; + values: string | string[] + ): Client>; elementIdValue

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

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

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

; + elements(selector: string): Client> & RawResult; + elements

(selector: string): Client

; } // Unuseful Protocol @@ -723,10 +659,10 @@ declare namespace WebdriverIO { // cookie // use selectorExecute instead - execute(script: string | Function, ...args: any[]): Client>; + execute(script: string | Function, ...args: any[]): Client> & RawResult; // use selectorExecuteAsync instead - executeAsync(script: string | Function, ...args: any[]): Client>; + executeAsync(script: string | Function, ...args: any[]): Client> & RawResult; // file // imeActivate @@ -746,45 +682,27 @@ declare namespace WebdriverIO { // use submitForm instead submit(id: ElementId): Client; - submit

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

; + submit

(id: ElementId): Client

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

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

; + isEnabled(selector?: string): Client; + isEnabled

(selector?: string): Client

; - isExisting(selector: string): Client; - isExisting

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

; + isExisting(selector?: string): Client; + isExisting

(selector?: string): Client

; - isSelected(selector: string): Client; - isSelected

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

; + isSelected(selector?: string): Client; + isSelected

(selector?: string): Client

; - isVisible(selector: string): Client; - isVisible

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

; + isVisible(selector?: string): Client; + isVisible

(selector?: string): Client

; - isVisibleWithinViewport(selector: string): Client; - isVisibleWithinViewport

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

; + isVisibleWithinViewport(selector?: string): Client; + isVisibleWithinViewport

(selector?: string): Client

; } export interface CommandHistoryEntry { @@ -794,183 +712,220 @@ declare namespace WebdriverIO { // Utility export interface Client { - addCommand(commandName: string, customMethod: Function, overwrite?: boolean): 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 + overwrite?: boolean ): Client

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

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

; + chooseFile

(localPath: string): Client

; debug(): Client; - debug

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

; + debug

(): Client

; end(): Client; - end

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

; + end

(): Client

; endAll(): Client; - endAll

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

; + endAll

(): Client

; getCommandHistory(): Client; - getCommandHistory

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

; + getCommandHistory

(): Client

; pause(milliseconds: number): Client; - pause

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

; + pause

(milliseconds: number): Client

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

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

; - saveScreenshot

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

; + saveScreenshot

(filename?: string): Client

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

( + scroll(selector?: string): Client; + scroll( selector: string, - callback: (err: any) => P - ): Client

; + xoffset: number, + yoffset: number + ): Client; + scroll( + xoffset: number, + yoffset: number + ): Client; + scroll

(selector?: string): Client

; scroll

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

; scroll

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

; uploadFile(localPath: string): Client; - uploadFile

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

; + uploadFile

(localPath: string): Client

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

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

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

(selector?: string): Client

; waitForEnabled

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

; + waitForEnabled

(milliseconds: number): Client

; waitForEnabled

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

; + waitForEnabled

( + milliseconds: number, + reverse: boolean ): Client

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

(selector?: string): Client

; waitForExist

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

; + waitForExist

(milliseconds: number): Client

; waitForExist

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

; waitForExist

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

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

(selector?: string): Client

; waitForSelected

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

; + waitForSelected

(milliseconds: number): Client

; waitForSelected

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

; waitForSelected

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

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

(selector?: string): Client

; waitForText

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

; + waitForText

(milliseconds: number): Client

; waitForText

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

; waitForText

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

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

(selector?: string): Client

; waitForValue

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

; - waitForValue

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

; + waitForValue

(milliseconds: number): 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, + waitForValue

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

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

(selector?: string): Client

; + waitForVisible

( + selector: string, + milliseconds: number + ): Client

; + waitForVisible

(milliseconds: number): Client

; + waitForVisible

( + selector: string, + milliseconds: number, + reverse: boolean + ): Client

; + waitForVisible

( + milliseconds: number, + reverse: boolean ): Client

; waitUntil( @@ -983,65 +938,49 @@ declare namespace WebdriverIO { condition: () => boolean | Q.IPromise, timeout?: number, timeoutMsg?: string, - interval?: number, - callback?: (err: any, enabled: boolean) => P + interval?: number ): Client

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

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

; - close

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

; + close

(windowHandle?: string): Client

; getCurrentTabId(): Client; - getCurrentTabId

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

; + getCurrentTabId

(): Client

; getTabIds(): Client; - getTabIds

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

; + getTabIds

(): Client

; - getViewportSize(): Client; + getViewportSize(): Client & Size; getViewportSize(dimension: string): Client; - getViewportSize

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

; - getViewportSize

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

; + getViewportSize

(dimension?: string): Client

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

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

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

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

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

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

; - switchTab

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

; + switchTab

(windowHandle?: string): Client

; } export interface Options { @@ -1085,3 +1024,4 @@ declare var browser: WebdriverIO.Client; declare module "webdriverio" { export = WebdriverIO; } + diff --git a/webdriverio/webdriverio-tests.ts b/webdriverio/webdriverio-tests.ts index 0e752e93ce..dc204b2052 100644 --- a/webdriverio/webdriverio-tests.ts +++ b/webdriverio/webdriverio-tests.ts @@ -6,15 +6,13 @@ import {assert} from "chai"; describe("webdriver.io page", function() { - it("should have the right title - the good old callback way", function(done) { - - browser - .url("/") - .getTitle(function(err, title) { - assert.equal(err, undefined); - assert.equal(title, "WebdriverIO - Selenium 2.0 javascript bindings for nodejs"); - }) - .call(done); + it("should have the right title - the good old callback way", function() { + assert.equal( + browser + .url("/") + .getTitle(), + "WebdriverIO - Selenium 2.0 javascript bindings for nodejs" + ); }); @@ -41,27 +39,28 @@ describe("my webdriverio tests", function(){ client.init(done); }); - it("Github test",function(done) { - client - .url("https://github.com/") - .getElementSize(".header-logo-wordmark", function(err: any, result: webdriverio.Size) { - assert.equal(undefined, err); - assert.strictEqual(result.height, 26); - assert.strictEqual(result.width, 89); - }) - .getTitle(function(err: any, title: string) { - assert.equal(undefined, err); - assert.strictEqual(title,"GitHub · Where software is built"); - }) - .getCssProperty("a[href='/plans']", "color", function(err: any, result: webdriverio.CssProperty){ - assert.equal(undefined, err); - assert.strictEqual(result.value, "rgba(64,120,192,1)"); - }) - .call(done); + it("Github test",function() { + client.url("https://github.com/"); + + var elementSize = client.getElementSize(".header-logo-wordmark"); + + var foo = client.getElementSize('div'); + + assert.isNumber(elementSize.height); + assert.isNumber(elementSize.width); + assert.strictEqual(elementSize.height, 26); + assert.strictEqual(elementSize.width, 89); + + var title = client.getTitle(); + assert.isString(title); + assert.strictEqual(title, "GitHub · Where software is built"); + + var cssProperty = client.getCssProperty("a[href='/plans']", "color"); + assert.strictEqual(cssProperty.value, "rgba(64,120,192,1)"); }); - after(function(done) { - client.end(done); + after(function() { + client.end(); }); });