mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
update CasperJS 1.0.29 to 1.1.4 (#20739)
* update CasperJS 1.0.29 to 1.1.4 remove most oh the any type Set Optional parameter As Optional. * tslint casperJS
This commit is contained in:
173
types/casperjs/index.d.ts
vendored
173
types/casperjs/index.d.ts
vendored
@@ -1,17 +1,17 @@
|
||||
// Type definitions for CasperJS v1.0.29
|
||||
// Type definitions for CasperJS 1.1
|
||||
// Project: http://casperjs.org/
|
||||
// Definitions by: Jed Mao <https://github.com/jedmao>
|
||||
// Uriel Chemouni <https://github.com/urielch>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="phantomjs" />
|
||||
|
||||
|
||||
export function create(options?: CasperOptions): Casper;
|
||||
|
||||
export function selectXPath(expression: string): Object;
|
||||
export function selectXPath(expression: string): object;
|
||||
|
||||
export class Casper {
|
||||
|
||||
constructor(options: CasperOptions);
|
||||
|
||||
test: Tester;
|
||||
@@ -23,23 +23,23 @@ export class Casper {
|
||||
// Methods
|
||||
back(): Casper;
|
||||
base64encode(url: string, method?: string, data?: any): string;
|
||||
bypass(nb: number): any;
|
||||
click(selector: string): boolean;
|
||||
bypass(nb: number): Casper;
|
||||
click(selector: string, X?: number | string, Y?: number | string): boolean;
|
||||
clickLabel(label: string, tag?: string): boolean;
|
||||
capture(targetFilePath: string, clipRect: ClipRect): Casper;
|
||||
captureBase64(format: string): string;
|
||||
captureBase64(format: string, area: string): string;
|
||||
captureBase64(format: string, area: ClipRect): string;
|
||||
captureBase64(format: string, area: any): string;
|
||||
captureSelector(targetFile: string, selector: string): Casper;
|
||||
capture(targetFilePath: string, clipRect?: ClipRect, imgOptions?: ImgOptions): Casper;
|
||||
captureBase64(format: string, area?: string | ClipRect | CasperSelector): string;
|
||||
captureSelector(targetFile: string, selector: string, imgOptions?: ImgOptions): Casper;
|
||||
clear(): Casper;
|
||||
clearCache(): Casper;
|
||||
clearMemoryCache(): Casper;
|
||||
debugHTML(selector?: string, outer?: boolean): Casper;
|
||||
debugPage(): Casper;
|
||||
die(message: string, status?: number): Casper;
|
||||
download(url: string, target?: string, method?: string, data?: any): Casper;
|
||||
download(url: string, target: string, method?: string, data?: any): Casper;
|
||||
each<T>(array: T[], fn: (this: Casper, item: T, index: number) => void): Casper;
|
||||
eachThen(array: any[], then?: FunctionThen): Casper;
|
||||
echo(message: string, style?: string): Casper;
|
||||
evaluate<T>(fn: (...args: any[]) => T, ...args: any[]): T
|
||||
evaluate<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||
evaluateOrDie(fn: () => any, message?: string, status?: number): Casper;
|
||||
exit(status?: number): Casper;
|
||||
exists(selector: string): boolean;
|
||||
@@ -52,7 +52,7 @@ export class Casper {
|
||||
getCurrentUrl(): string;
|
||||
getElementAttribute(selector: string, attribute: string): string;
|
||||
getElementsAttribute(selector: string, attribute: string): string;
|
||||
getElementBounds(selector: string): ElementBounds;
|
||||
getElementBounds(selector: string, page?: boolean): ElementBounds | null;
|
||||
getElementsBounds(selector: string): ElementBounds[];
|
||||
getElementInfo(selector: string): ElementInfo;
|
||||
getElementsInfo(selector: string): ElementInfo;
|
||||
@@ -61,83 +61,125 @@ export class Casper {
|
||||
getHTML(selector?: string, outer?: boolean): string;
|
||||
getPageContent(): string;
|
||||
getTitle(): string;
|
||||
mouseEvent(type: string, selector: string): boolean;
|
||||
mouseEvent(type: string, selector: string, X?: number|string, Y?: number|string): boolean;
|
||||
newPage(): any;
|
||||
open(location: string, settings: OpenSettings): Casper;
|
||||
reload(then?: (response: HttpResponse) => void): Casper;
|
||||
repeat(times: number, then: Function): Casper;
|
||||
resourceExists(test: Function): boolean;
|
||||
resourceExists(test: string): boolean;
|
||||
run(onComplete: Function, time?: number): Casper;
|
||||
reload(then?: FunctionThen): Casper;
|
||||
repeat(times: number, then: FunctionThen): Casper;
|
||||
resourceExists(test: string | Function | RegExp): boolean;
|
||||
run(onComplete?: Function, time?: number): Casper;
|
||||
scrollTo(x: number, y: number): Casper;
|
||||
scrollToBottom(): Casper;
|
||||
sendKeys(selector: string, keys: string, options?: any): Casper;
|
||||
sendKeys(selector: string, keys: string, options?: KeyOptions): Casper;
|
||||
setHttpAuth(username: string, password: string): Casper;
|
||||
start(url?: string, then?: (response: HttpResponse) => void): Casper;
|
||||
status(asString: boolean): any;
|
||||
setMaxListeners(maxListeners: number): Casper;
|
||||
start(url?: string, then?: FunctionThen): Casper;
|
||||
status(asString?: false): number;
|
||||
status(asString: true): string;
|
||||
switchToFrame(frameInfo: string | number): Casper;
|
||||
switchToMainFrame(): Casper;
|
||||
switchToParentFrame(): Casper;
|
||||
then(fn: (this: Casper) => void): Casper;
|
||||
thenBypass(nb: number): Casper;
|
||||
thenBypassIf(condition: any, nb: number): Casper;
|
||||
thenBypassUnless(condition: any, nb: number): Casper;
|
||||
thenClick(selector: string): Casper;
|
||||
thenClick(selector: string, then?: FunctionThen): Casper;
|
||||
thenEvaluate(fn: () => any, ...args: any[]): Casper;
|
||||
thenOpen(location: string, then?: (response: HttpResponse) => void): Casper;
|
||||
thenOpen(location: string, options?: OpenSettings, then?: (response: HttpResponse) => void): Casper;
|
||||
thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]): Casper;
|
||||
thenOpenAndEvaluate(location: string, then?: FunctionThen, ...args: any[]): Casper;
|
||||
toString(): string;
|
||||
unwait(): Casper;
|
||||
userAgent(agent: string): string;
|
||||
viewport(width: number, height: number): Casper;
|
||||
// 2017-10-19 Doc said returning String but code return Casper object.
|
||||
userAgent(agent: string): Casper;
|
||||
viewport(width: number, height: number, then?: FunctionThen): Casper;
|
||||
visible(selector: string): boolean;
|
||||
wait(timeout: number, then?: Function): Casper;
|
||||
waitFor(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForAlert(then: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForPopup(urlPattern: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForPopup(urlPattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForUrl(url: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForUrl(url: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitWhileSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForResource(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForText(pattern: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForText(pattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitUntilVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitWhileVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
|
||||
wait(timeout: number, then?: FunctionThen): Casper;
|
||||
waitFor(testFx: Function, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number, details?: any): Casper;
|
||||
waitForAlert(then: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitForExec(command: string | null, parameter: string[], then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitForPopup(urlPattern: RegExp | string | number | FindByUrlNameTitle, then?: FunctionThen, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForResource(testFx: RegExp | string | ((resource: {url: string}) => boolean), then?: FunctionThen, onTimeout?: Function, timeout?: number): Casper;
|
||||
waitForUrl(url: RegExp | string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitForSelector(selector: string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitWhileSelector(selector: string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitForSelectorTextChange(selectors: string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitForText(pattern: RegExp | string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitUntilVisible(selector: string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
waitWhileVisible(selector: string, then?: FunctionThen, onTimeout?: FunctionOnTimeout, timeout?: number): Casper;
|
||||
warn(message: string): Casper;
|
||||
withFrame(frameInfo: string, then: Function): Casper;
|
||||
withFrame(frameInfo: number, then: Function): Casper;
|
||||
withPopup(popupInfo: string, step: Function): Casper;
|
||||
withPopup(popupInfo: RegExp, step: Function): Casper;
|
||||
withFrame(frameInfo: string | number, then: FunctionThen): Casper;
|
||||
withPopup(popupInfo: RegExp | string | number | FindByUrlNameTitle, step: FunctionThen): Casper;
|
||||
withSelectorScope(selector: string, then: FunctionThen): Casper;
|
||||
zoom(factor: number): Casper;
|
||||
removeAllFilters(filter: string): Casper;
|
||||
setFilter(filter: string, cb: Function): boolean;
|
||||
// do not exists anymore
|
||||
// removeAllFilters(filter: string): Casper;
|
||||
// do not exists anymore
|
||||
// setFilter(filter: string, cb: Function): boolean;
|
||||
}
|
||||
|
||||
interface HttpResponse {
|
||||
export type FunctionThen = (this: Casper, response: HttpResponse) => void;
|
||||
export type FunctionOnTimeout = (this: Casper, timeout: number, details: any) => void;
|
||||
// not visible in doc
|
||||
// interface QtRuntimeObject {id?: any; url?: string;}
|
||||
// see modules/pagestack.js in casperjs
|
||||
|
||||
export interface ImgOptions {
|
||||
// format to set the image format manually, avoiding relying on the filename
|
||||
format?: string;
|
||||
// quality to set the image quality, from 1 to 100
|
||||
quality?: number;
|
||||
}
|
||||
|
||||
export interface FindByUrlNameTitle {
|
||||
url?: string;
|
||||
title?: string;
|
||||
windowName?: string;
|
||||
}
|
||||
|
||||
export interface Header {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface CasperSelector {
|
||||
type?: 'xpath' | 'css';
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface KeyOptions {
|
||||
reset?: boolean;
|
||||
keepFocus?: boolean;
|
||||
modifiers?: string; // combinaison of 'ctrl+alt+shift+meta+keypad'
|
||||
}
|
||||
|
||||
export interface HttpResponse {
|
||||
contentType: string;
|
||||
headers: any[];
|
||||
headers: Header[];
|
||||
id: number;
|
||||
redirectURL: string;
|
||||
redirectURL: string | null;
|
||||
stage: string;
|
||||
status: number;
|
||||
statusText: string;
|
||||
time: string;
|
||||
url: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface OpenSettings {
|
||||
export interface OpenSettings {
|
||||
method: string;
|
||||
data: any;
|
||||
headers: any;
|
||||
}
|
||||
|
||||
interface ElementBounds {
|
||||
export interface ElementBounds {
|
||||
top: number;
|
||||
left: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface ElementInfo {
|
||||
export interface ElementInfo {
|
||||
nodeName: string;
|
||||
attributes: any;
|
||||
tag: string;
|
||||
@@ -150,7 +192,7 @@ interface ElementInfo {
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
interface CasperOptions {
|
||||
export interface CasperOptions {
|
||||
clientScripts?: any[];
|
||||
exitOnError?: boolean;
|
||||
httpStatusHandlers?: any;
|
||||
@@ -179,7 +221,7 @@ interface CasperOptions {
|
||||
waitTimeout?: number;
|
||||
}
|
||||
|
||||
interface ClientUtils {
|
||||
export interface ClientUtils {
|
||||
echo(message: string): void;
|
||||
encode(contents: string): void;
|
||||
exists(selector: string): void;
|
||||
@@ -200,12 +242,12 @@ interface ClientUtils {
|
||||
visible(selector: string): void;
|
||||
}
|
||||
|
||||
interface Colorizer {
|
||||
export interface Colorizer {
|
||||
colorize(text: string, styleName: string): void;
|
||||
format(text: string, style: any): void;
|
||||
}
|
||||
|
||||
interface Tester {
|
||||
export interface Tester {
|
||||
assert(condition: boolean, message?: string): any;
|
||||
assertDoesntExist(selector: string, message?: string): any;
|
||||
assertElementCount(selctor: string, expected: number, message?: string): any;
|
||||
@@ -235,15 +277,14 @@ interface Tester {
|
||||
assertTruthy(subject: any, message?: string): any;
|
||||
assertType(input: any, type: string, message?: string): any;
|
||||
assertInstanceOf(input: any, ctor: Function, message?: string): any;
|
||||
assertUrlMatch(pattern: string, message?: string): any;
|
||||
assertUrlMatch(pattern: RegExp, message?: string): any;
|
||||
assertUrlMatch(pattern: RegExp | string, message?: string): any;
|
||||
assertVisible(selector: string, message?: string): any;
|
||||
|
||||
/* since 1.1 */
|
||||
begin(description: string, planned: number, suite: Function): any;
|
||||
begin(description: string, suite: Function): any;
|
||||
begin(description: string, planned: number, config: Object): any;
|
||||
begin(description: string, config: Object): any;
|
||||
begin(description: string, planned: number, config: object): any;
|
||||
begin(description: string, config: object): any;
|
||||
|
||||
colorize(message: string, style: string): any;
|
||||
comment(message: string): any;
|
||||
@@ -262,12 +303,12 @@ interface Tester {
|
||||
tearDown(fn: Function): any;
|
||||
}
|
||||
|
||||
interface Cases {
|
||||
export interface Cases {
|
||||
length: number;
|
||||
cases: Case[];
|
||||
}
|
||||
|
||||
interface Case {
|
||||
export interface Case {
|
||||
success: boolean;
|
||||
type: string;
|
||||
standard: string;
|
||||
@@ -275,12 +316,12 @@ interface Case {
|
||||
values: CaseValues;
|
||||
}
|
||||
|
||||
interface CaseValues {
|
||||
export interface CaseValues {
|
||||
subject: boolean;
|
||||
expected: boolean;
|
||||
}
|
||||
|
||||
interface Utils {
|
||||
export interface Utils {
|
||||
betterTypeOf(input: any): any;
|
||||
dump(value: any): any;
|
||||
fileExt(file: string): any;
|
||||
|
||||
12
types/casperjs/tslint.json
Normal file
12
types/casperjs/tslint.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// need to fix some Function type
|
||||
"ban-types": false,
|
||||
// can not merge
|
||||
// begin(description: string, planned: number, suite: Function): any;
|
||||
// and
|
||||
// begin(description: string, planned: number, config: object): any;
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user