protractor-helpers: Use latest jasmine and selenium-webdriver (#15465)

This commit is contained in:
Andy
2017-03-29 09:41:34 -07:00
committed by GitHub
parent dff931c5af
commit 8c87f40c10
4 changed files with 84 additions and 92 deletions

View File

@@ -4,107 +4,101 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="selenium-webdriver" />
/// <reference types="jasmine" />
import * as webdriver from "selenium-webdriver";
// ElementArrayFinder
declare global {
// ElementArrayFinder
declare namespace protractor {
interface ElementArrayFinder {
getByText(text: string) : protractor.ElementFinder;
$$data(hook: string) : protractor.ElementArrayFinder;
namespace protractor {
interface ElementArrayFinder {
getByText(text: string) : protractor.ElementFinder;
$$data(hook: string) : protractor.ElementArrayFinder;
}
interface ElementFinder {
$data(hook: string) : protractor.ElementFinder;
}
}
interface ElementFinder {
$data(hook: string) : protractor.ElementFinder;
// Globals
function $data(hook: string) : protractor.ElementFinder;
function $$data(hook: string) : protractor.ElementArrayFinder;
// Locators
// TODO - find out about result of querySelector and querySelector all.
// Are they Locator s?
namespace protractor {
interface IProtractorLocatorStrategy {
dataHook(hook: string, optParentElement?: protractor.ElementFinder, optRootSelector?: string) : webdriver.Locator;
dataHookAll(hook: string, optParentElement?: protractor.ElementFinder, optRootSelector?: string) : webdriver.Locator;
}
}
// Matchers
// TODO - Use `T` to improve types
namespace jasmine {
interface Matchers<T> {
toBePresent() : boolean;
toBeDisplayed() : boolean;
toHaveCountOf(expectedCount : number) : boolean;
toHaveText(expectedText : string) : boolean;
toMatchRegex(regex : RegExp) : boolean;
toMatchMoney(expectedValue : number, currencySymbol? : string) : boolean;
toMatchMoneyWithFraction(expectedValue : number, currencySymbol?: string) : boolean;
toHaveValue(actual: string | number) : boolean;
toHaveClass(className : string) : boolean;
toHaveUrl(url : string) : boolean;
toBeDisabled() : boolean;
toBeChecked() : boolean;
toBeValid() : boolean;
toBeInvalid() : boolean;
toBeInvalidRequired() : boolean;
// Copied definitions from angular-translate.
toMatchTranslated(translationId : string, interpolateParams? : any) : boolean;
toMatchTranslated(translationId : string[], interpolateParams? : any) : boolean;
}
}
}
// Globals
export function not(arg: webdriver.promise.IThenable<any>) : webdriver.promise.IThenable<boolean>;
declare function $data(hook: string) : protractor.ElementFinder;
declare function $$data(hook: string) : protractor.ElementArrayFinder;
// Copied definitions from angular-translate.
export function translate(translationId: string, interpolateParams?: any): webdriver.promise.IThenable<string>;
export function translate(translationId: string[], interpolateParams?: any): webdriver.promise.IThenable<{ [key: string]: string }>;
export function safeGet(url: string) : void;
// Locators
export function maximizeWindow(width?: number, height?: number) : void; // TODO
export function resetPosition() : void;
export function moveToElement(hook: string) : void;
export function displayHover(element: protractor.ElementFinder) : void;
// TODO - find out about result of querySelector and querySelector all.
// Are they Locator s?
declare namespace protractor {
interface IProtractorLocatorStrategy {
dataHook(hook: string, optParentElement?: protractor.ElementFinder, optRootSelector?: string) : webdriver.Locator;
dataHookAll(hook: string, optParentElement?: protractor.ElementFinder, optRootSelector?: string) : webdriver.Locator;
}
}
export function waitForElement(element: protractor.ElementFinder, timeout?: number) : void;
export function waitForElementToDisappear(element: protractor.ElementFinder, timeout?: number) : void;
// Matchers
// TODO - Typescript doesn't really help much here
// we don't know what type is being tested.
// Fixing this would require modifying the
// jasmine d.ts.
export function selectOptionByText(select: protractor.ElementFinder, text: string) : void;
export function selectOptionByIndex(select: protractor.ElementFinder, index: number) : void;
declare namespace jasmine {
interface Matchers<T> {
toBePresent() : boolean;
toBeDisplayed() : boolean;
toHaveCountOf(expectedCount : number) : boolean;
toHaveText(expectedText : string) : boolean;
toMatchRegex(regex : RegExp) : boolean;
toMatchMoney(expectedValue : number, currencySymbol? : string) : boolean;
toMatchMoneyWithFraction(expectedValue : number, currencySymbol?: string) : boolean;
toHaveValue(actual: string | number) : boolean;
toHaveClass(className : string) : boolean;
toHaveUrl(url : string) : boolean;
toBeDisabled() : boolean;
toBeChecked() : boolean;
toBeValid() : boolean;
toBeInvalid() : boolean;
toBeInvalidRequired() : boolean;
// Copied definitions from angular-translate.
toMatchTranslated(translationId : string, interpolateParams? : any) : boolean;
toMatchTranslated(translationId : string[], interpolateParams? : any) : boolean;
}
}
export function selectOption(option: protractor.ElementFinder) : void
export function isFirefox() : boolean;
export function isIE() : boolean;
declare module "protractor-helpers" {
export function createMessage(actual : string, message : string, isNot : any) : string; // isNot : boolean too inflexible
export function createMessage(actual : protractor.ElementFinder, message : string, isNot : any) : string; // isNot : boolean too inflexible
export function createMessage(actual : protractor.ElementArrayFinder, message : string, isNot : any) : string; // isNot : boolean too inflexible
function not(arg: webdriver.promise.IThenable<any>) : webdriver.promise.IThenable<boolean>;
export function clearAndSetValue(input : protractor.ElementFinder, value : string) : void; // TODO - sendKeys(value)
// Copied definitions from angular-translate.
function translate(translationId: string, interpolateParams?: any): webdriver.promise.IThenable<string>;
function translate(translationId: string[], interpolateParams?: any): webdriver.promise.IThenable<{ [key: string]: string }>;
function safeGet(url: string) : void;
function maximizeWindow(width?: number, height?: number) : void; // TODO
function resetPosition() : void;
function moveToElement(hook: string) : void;
function displayHover(element: protractor.ElementFinder) : void;
function waitForElement(element: protractor.ElementFinder, timeout?: number) : void;
function waitForElementToDisappear(element: protractor.ElementFinder, timeout?: number) : void;
function selectOptionByText(select: protractor.ElementFinder, text: string) : void;
function selectOptionByIndex(select: protractor.ElementFinder, index: number) : void;
function selectOption(option: protractor.ElementFinder) : void
function isFirefox() : boolean;
function isIE() : boolean;
function createMessage(actual : string, message : string, isNot : any) : string; // isNot : boolean too inflexible
function createMessage(actual : protractor.ElementFinder, message : string, isNot : any) : string; // isNot : boolean too inflexible
function createMessage(actual : protractor.ElementArrayFinder, message : string, isNot : any) : string; // isNot : boolean too inflexible
function clearAndSetValue(input : protractor.ElementFinder, value : string) : void; // TODO - sendKeys(value)
function hasClass(element: protractor.ElementFinder, className: string) : webdriver.promise.IThenable<boolean>;
function hasValue(element: protractor.ElementFinder, expectedValue: string) : webdriver.promise.IThenable<boolean>;
function hasValue(element: protractor.ElementFinder, expectedValue: number) : webdriver.promise.IThenable<boolean>;
function hasLink(element: protractor.ElementFinder, url: string) : webdriver.promise.IThenable<boolean>;
function isDisabled(element: protractor.ElementFinder) : webdriver.promise.IThenable<boolean>;
function isChecked(element: protractor.ElementFinder) : webdriver.promise.IThenable<boolean>;
function getFilteredConsoleErrors() : webdriver.promise.IThenable<string[]>; // TODO - discuss handling in IE
}
export function hasClass(element: protractor.ElementFinder, className: string) : webdriver.promise.IThenable<boolean>;
export function hasValue(element: protractor.ElementFinder, expectedValue: string) : webdriver.promise.IThenable<boolean>;
export function hasValue(element: protractor.ElementFinder, expectedValue: number) : webdriver.promise.IThenable<boolean>;
export function hasLink(element: protractor.ElementFinder, url: string) : webdriver.promise.IThenable<boolean>;
export function isDisabled(element: protractor.ElementFinder) : webdriver.promise.IThenable<boolean>;
export function isChecked(element: protractor.ElementFinder) : webdriver.promise.IThenable<boolean>;
export function getFilteredConsoleErrors() : webdriver.promise.IThenable<string[]>; // TODO - discuss handling in IE

View File

@@ -1,6 +0,0 @@
{
"dependencies": {
"@types/jasmine": "^2.2.34",
"@types/selenium-webdriver": "2.44.28"
}
}

View File

@@ -1,4 +1,5 @@
import helpers = require('protractor-helpers');
import * as webdriver from "selenium-webdriver";
declare var $$: any, $: any, by: any, element: any; // ??

View File

@@ -8,6 +8,9 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true