forked from angular/protractor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): Support setting
SELENIUM_PROMISE_MANAGER
flag via the…
… config (angular#4023) Closes angular#3691
- Loading branch information
Showing
11 changed files
with
235 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./spec/built/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
// Based off of spec/basic/elements_spec.js | ||
import {promise as ppromise, browser, element, by, By, $, $$, ExpectedConditions, ElementFinder} from '../../..'; | ||
|
||
describe('ElementFinder', function() { | ||
it('should return the same result as browser.findElement', async function() { | ||
await browser.get('index.html#/form'); | ||
const nameByElement = element(by.binding('username')); | ||
|
||
await expect(nameByElement.getText()).toEqual( | ||
browser.findElement(by.binding('username')).getText()); | ||
}); | ||
|
||
it('should wait to grab the WebElement until a method is called', async function() { | ||
// These should throw no error before a page is loaded. | ||
const usernameInput = element(by.model('username')); | ||
const name = element(by.binding('username')); | ||
|
||
await browser.get('index.html#/form'); | ||
|
||
await expect(name.getText()).toEqual('Anon'); | ||
|
||
await usernameInput.clear(); | ||
await usernameInput.sendKeys('Jane'); | ||
await expect(name.getText()).toEqual('Jane'); | ||
}); | ||
|
||
it('should chain element actions', async function() { | ||
await browser.get('index.html#/form'); | ||
|
||
const usernameInput = element(by.model('username')); | ||
const name = element(by.binding('username')); | ||
|
||
await expect(name.getText()).toEqual('Anon'); | ||
|
||
await ((usernameInput.clear() as any) as ElementFinder).sendKeys('Jane'); | ||
await expect(name.getText()).toEqual('Jane'); | ||
}); | ||
|
||
it('chained call should wait to grab the WebElement until a method is called', | ||
async function() { | ||
// These should throw no error before a page is loaded. | ||
const reused = element(by.id('baz')). | ||
element(by.binding('item.reusedBinding')); | ||
|
||
await browser.get('index.html#/conflict'); | ||
|
||
await expect(reused.getText()).toEqual('Inner: inner'); | ||
await expect(reused.isPresent()).toBe(true); | ||
}); | ||
|
||
it('should differentiate elements with the same binding by chaining', | ||
async function() { | ||
await browser.get('index.html#/conflict'); | ||
|
||
const outerReused = element(by.binding('item.reusedBinding')); | ||
const innerReused = | ||
element(by.id('baz')).element(by.binding('item.reusedBinding')); | ||
|
||
await expect(outerReused.getText()).toEqual('Outer: outer'); | ||
await expect(innerReused.getText()).toEqual('Inner: inner'); | ||
}); | ||
|
||
it('should chain deeper than 2', async function() { | ||
// These should throw no error before a page is loaded. | ||
const reused = element(by.css('body')).element(by.id('baz')). | ||
element(by.binding('item.reusedBinding')); | ||
|
||
await browser.get('index.html#/conflict'); | ||
|
||
await expect(reused.getText()).toEqual('Inner: inner'); | ||
}); | ||
|
||
it('should allow handling errors', async function() { | ||
await browser.get('index.html#/form'); | ||
try { | ||
await $('.nopenopenope').getText(); | ||
|
||
// The above line should have throw an error. Fail. | ||
await expect(true).toEqual(false); | ||
} catch (e) { | ||
await expect(true).toEqual(true); | ||
} | ||
}); | ||
|
||
it('should allow handling chained errors', async function() { | ||
await browser.get('index.html#/form'); | ||
try { | ||
await $('.nopenopenope').$('furthernope').getText(); | ||
|
||
// The above line should have throw an error. Fail. | ||
await expect(true).toEqual(false); | ||
} catch (e) { | ||
await expect(true).toEqual(true); | ||
} | ||
}); | ||
|
||
it('should keep a reference to the original locator', async function() { | ||
await browser.get('index.html#/form'); | ||
|
||
const byCss = by.css('body'); | ||
const byBinding = by.binding('greet'); | ||
|
||
await expect(element(byCss).locator()).toEqual(byCss); | ||
await expect(element(byBinding).locator()).toEqual(byBinding); | ||
}); | ||
|
||
it('should propagate exceptions', async function() { | ||
await browser.get('index.html#/form'); | ||
|
||
const invalidElement = element(by.binding('INVALID')); | ||
const successful = invalidElement.getText().then(function() { | ||
return true; | ||
} as any as (() => ppromise.Promise<void>), function() { | ||
return false; | ||
} as any as (() => ppromise.Promise<void>)); | ||
await expect(successful).toEqual(false); | ||
}); | ||
|
||
it('should be returned from a helper without infinite loops', async function() { | ||
await browser.get('index.html#/form'); | ||
const helperPromise = ppromise.when(true).then(function() { | ||
return element(by.binding('greeting')); | ||
}); | ||
|
||
await helperPromise.then(async function(finalResult: ElementFinder) { | ||
await expect(finalResult.getText()).toEqual('Hiya'); | ||
} as any as (() => ppromise.Promise<void>)); | ||
}); | ||
|
||
it('should be usable in WebDriver functions', async function() { | ||
await browser.get('index.html#/form'); | ||
const greeting = element(by.binding('greeting')); | ||
await browser.executeScript('arguments[0].scrollIntoView', greeting); | ||
}); | ||
|
||
it('should allow null as success handler', async function() { | ||
await browser.get('index.html#/form'); | ||
|
||
const name = element(by.binding('username')); | ||
|
||
await expect(name.getText()).toEqual('Anon'); | ||
await expect( | ||
name.getText().then(null, function() {}) | ||
).toEqual('Anon'); | ||
|
||
}); | ||
|
||
it('should check equality correctly', async function() { | ||
await browser.get('index.html#/form'); | ||
|
||
const usernameInput = element(by.model('username')); | ||
const name = element(by.binding('username')); | ||
|
||
await expect(usernameInput.equals(usernameInput)).toEqual(true); | ||
await expect(usernameInput.equals(name)).toEqual(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Config} from '../..'; | ||
const env = require('../environment.js'); | ||
|
||
export let config: Config = { | ||
seleniumAddress: env.seleniumAddress, | ||
|
||
framework: 'jasmine', | ||
|
||
specs: [ | ||
'noCF/smoke_spec.js' | ||
], | ||
|
||
capabilities: env.capabilities, | ||
|
||
baseUrl: env.baseUrl + '/ng1/', | ||
|
||
SELENIUM_PROMISE_MANAGER: false | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"removeComments": false, | ||
"noImplicitAny": true, | ||
"outDir": "spec/built", | ||
"types": [ | ||
"jasmine", "jasminewd2", "node", | ||
"chalk", "glob", "minimatch", | ||
"minimist", "optimist", "q", | ||
"selenium-webdriver" | ||
] | ||
}, | ||
"include": [ | ||
"spec/ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters