Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix(protractor): Corrected the Text.of and Text.ofAll questions
- Loading branch information
Showing
with
157 additions
and 4 deletions.
- +1 −1 packages/protractor/spec/protractor.conf.js
- +0 −1 packages/protractor/spec/screenplay/interactions/Enter.spec.ts
- +22 −0 packages/protractor/spec/screenplay/questions/Attribute.spec.ts
- +51 −0 packages/protractor/spec/screenplay/questions/Text.spec.ts
- +32 −0 packages/protractor/spec/screenplay/questions/Value.spec.ts
- +38 −0 packages/protractor/spec/screenplay/questions/Website.spec.ts
- +10 −0 packages/protractor/src/screenplay/abilities/BrowseTheWeb.ts
- +3 −2 packages/protractor/src/screenplay/questions/Text.ts
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
@@ -3,7 +3,7 @@ | ||
exports.config = { | ||
chromeDriver: require(`chromedriver/lib/chromedriver`).path, | ||
|
||
SELENIUM_PROMISE_MANAGER: false, | ||
|
||
onPrepare: function() { | ||
return browser.waitForAngularEnabled(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
@@ -37,6 +37,5 @@ describe('Enter', () => { | ||
Enter.theValue(Bernie.name).into(Form.Field), | ||
|
||
Ensure.that(Value.of(Form.Field), equals(Bernie.name)), | ||
)); | ||
}); |
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
@@ -0,0 +1,22 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { Actor } from '@serenity-js/core'; | ||
import { by, protractor } from 'protractor'; | ||
|
||
import { Attribute, BrowseTheWeb, Navigate, Target } from '../../../src'; | ||
import { pageFromTemplate } from '../../fixtures'; | ||
|
||
describe('Attribute', () => { | ||
|
||
const Bernie = Actor.named('Bernie').whoCan( | ||
BrowseTheWeb.using(protractor.browser), | ||
); | ||
|
||
/** @test {Attribute} */ | ||
it('allows the actor to read an attribute of a DOM element', () => Bernie.attemptsTo( | ||
Navigate.to(pageFromTemplate(` | ||
<html lang="en" /> | ||
`)), | ||
|
||
Ensure.that(Attribute.of(Target.the('DOM').located(by.tagName('html'))).called('lang'), equals('en')), | ||
)); | ||
}); |
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
@@ -0,0 +1,51 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { Actor } from '@serenity-js/core'; | ||
import { by, protractor } from 'protractor'; | ||
|
||
import { BrowseTheWeb, Navigate, Target, Text } from '../../../src'; | ||
import { pageFromTemplate } from '../../fixtures'; | ||
|
||
describe('Text', function() { | ||
|
||
const Bernie = Actor.named('Bernie').whoCan( | ||
BrowseTheWeb.using(protractor.browser), | ||
); | ||
|
||
describe('of', () => { | ||
|
||
/** @test {Text} */ | ||
/** @test {Text.of} */ | ||
it('allows the actor to read the text of the DOM element matching the locator', () => Bernie.attemptsTo( | ||
Navigate.to(pageFromTemplate(` | ||
<html> | ||
<body> | ||
<h1>Hello World!</h1> | ||
</body> | ||
</html> | ||
`)), | ||
|
||
Ensure.that(Text.of(Target.the('header').located(by.tagName('h1'))), equals('Hello World!')), | ||
)); | ||
}); | ||
|
||
describe('ofAll', () => { | ||
|
||
/** @test {Text} */ | ||
/** @test {Text.ofAll} */ | ||
it('allows the actor to read the text of all DOM elements matching the locator', () => Bernie.attemptsTo( | ||
Navigate.to(pageFromTemplate(` | ||
<html> | ||
<body> | ||
<h1>Shopping list</h1> | ||
<ul> | ||
<li>milk</li> | ||
<li>oats</li> | ||
</ul> | ||
</body> | ||
</html> | ||
`)), | ||
|
||
Ensure.that(Text.ofAll(Target.all('shopping list items').located(by.css('li'))), equals(['milk', 'oats'])), | ||
)); | ||
}); | ||
}); |
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
@@ -0,0 +1,32 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { Actor } from '@serenity-js/core'; | ||
import { by, protractor } from 'protractor'; | ||
|
||
import { BrowseTheWeb, Navigate, Target, Value } from '../../../src'; | ||
import { pageFromTemplate } from '../../fixtures'; | ||
|
||
describe('Value', function() { | ||
|
||
const Bernie = Actor.named('Bernie').whoCan( | ||
BrowseTheWeb.using(protractor.browser), | ||
); | ||
|
||
describe('of', () => { | ||
|
||
/** @test {Text} */ | ||
/** @test {Text.of} */ | ||
it(`allows the actor to read the 'value' attribute of a DOM element matching the locator`, () => Bernie.attemptsTo( | ||
Navigate.to(pageFromTemplate(` | ||
<html> | ||
<body> | ||
<form> | ||
<input name="username" value="jan-molak" /> | ||
</form> | ||
</body> | ||
</html> | ||
`)), | ||
|
||
Ensure.that(Value.of(Target.the('username field').located(by.tagName('input'))), equals('jan-molak')), | ||
)); | ||
}); | ||
}); |
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
@@ -0,0 +1,38 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { Actor } from '@serenity-js/core'; | ||
import { protractor } from 'protractor'; | ||
|
||
import { BrowseTheWeb, Navigate, Website } from '../../../src'; | ||
import { pageFromTemplate } from '../../fixtures'; | ||
|
||
describe('Website', () => { | ||
|
||
const Bernie = Actor.named('Bernie').whoCan( | ||
BrowseTheWeb.using(protractor.browser), | ||
); | ||
|
||
describe('title', () => { | ||
/** @test {Attribute} */ | ||
it('allows the actor to read an attribute of a DOM element', () => Bernie.attemptsTo( | ||
Navigate.to(pageFromTemplate(` | ||
<html> | ||
<head> | ||
<title>Hello World</title> | ||
</head> | ||
</html> | ||
`)), | ||
|
||
Ensure.that(Website.title(), equals(`Hello World`)), | ||
)); | ||
}); | ||
|
||
describe('url', () => { | ||
|
||
/** @test {Attribute} */ | ||
it('allows the actor to read an attribute of a DOM element', () => Bernie.attemptsTo( | ||
Navigate.to(`chrome://accessibility/`), | ||
|
||
Ensure.that(Website.url(), equals(`chrome://accessibility/`)), | ||
)); | ||
}); | ||
}); |
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