From e6177174c42636f9c2452016dbd98a54f81c18b6 Mon Sep 17 00:00:00 2001 From: Ruslan Grabovoy Date: Wed, 18 Oct 2017 22:51:29 +0300 Subject: [PATCH 1/5] create v1.13.x --- docs/v1.13.x/api/alias.md | 84 ++++++ docs/v1.13.x/api/as.md | 61 +++++ docs/v1.13.x/api/attribute.md | 76 ++++++ docs/v1.13.x/api/click-on-text.md | 93 +++++++ docs/v1.13.x/api/clickable.md | 72 +++++ docs/v1.13.x/api/collection.md | 123 +++++++++ docs/v1.13.x/api/contains.md | 94 +++++++ docs/v1.13.x/api/count.md | 83 ++++++ docs/v1.13.x/api/create.md | 112 ++++++++ docs/v1.13.x/api/fillable.md | 127 +++++++++ docs/v1.13.x/api/getter.md | 55 ++++ docs/v1.13.x/api/has-class.md | 95 +++++++ docs/v1.13.x/api/is-hidden.md | 101 +++++++ docs/v1.13.x/api/is-present.md | 87 ++++++ docs/v1.13.x/api/is-visible.md | 107 ++++++++ docs/v1.13.x/api/is.md | 51 ++++ docs/v1.13.x/api/not-has-class.md | 95 +++++++ docs/v1.13.x/api/property.md | 62 +++++ docs/v1.13.x/api/text.md | 94 +++++++ docs/v1.13.x/api/triggerable.md | 97 +++++++ docs/v1.13.x/api/value.md | 83 ++++++ docs/v1.13.x/api/visitable.md | 58 ++++ docs/v1.13.x/components.md | 250 ++++++++++++++++++ docs/v1.13.x/extend.md | 82 ++++++ docs/v1.13.x/index.md | 55 ++++ docs/v1.13.x/installation.md | 10 + docs/v1.13.x/migrating.md | 340 ++++++++++++++++++++++++ docs/v1.13.x/options.md | 123 +++++++++ docs/v1.13.x/quickstart.md | 424 ++++++++++++++++++++++++++++++ 29 files changed, 3194 insertions(+) create mode 100644 docs/v1.13.x/api/alias.md create mode 100644 docs/v1.13.x/api/as.md create mode 100644 docs/v1.13.x/api/attribute.md create mode 100644 docs/v1.13.x/api/click-on-text.md create mode 100644 docs/v1.13.x/api/clickable.md create mode 100644 docs/v1.13.x/api/collection.md create mode 100644 docs/v1.13.x/api/contains.md create mode 100644 docs/v1.13.x/api/count.md create mode 100644 docs/v1.13.x/api/create.md create mode 100644 docs/v1.13.x/api/fillable.md create mode 100644 docs/v1.13.x/api/getter.md create mode 100644 docs/v1.13.x/api/has-class.md create mode 100644 docs/v1.13.x/api/is-hidden.md create mode 100644 docs/v1.13.x/api/is-present.md create mode 100644 docs/v1.13.x/api/is-visible.md create mode 100644 docs/v1.13.x/api/is.md create mode 100644 docs/v1.13.x/api/not-has-class.md create mode 100644 docs/v1.13.x/api/property.md create mode 100644 docs/v1.13.x/api/text.md create mode 100644 docs/v1.13.x/api/triggerable.md create mode 100644 docs/v1.13.x/api/value.md create mode 100644 docs/v1.13.x/api/visitable.md create mode 100644 docs/v1.13.x/components.md create mode 100644 docs/v1.13.x/extend.md create mode 100644 docs/v1.13.x/index.md create mode 100644 docs/v1.13.x/installation.md create mode 100644 docs/v1.13.x/migrating.md create mode 100644 docs/v1.13.x/options.md create mode 100644 docs/v1.13.x/quickstart.md diff --git a/docs/v1.13.x/api/alias.md b/docs/v1.13.x/api/alias.md new file mode 100644 index 00000000..1b4dfcc0 --- /dev/null +++ b/docs/v1.13.x/api/alias.md @@ -0,0 +1,84 @@ +--- +layout: page +title: Alias +--- + +{% raw %} +### Methods + +- [alias](#alias) + +## alias + +[addon/-private/properties/alias.js:80-102](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/alias.js#L80-L102 "Source code on GitHub") + +Returns the value of some other property on the PageObject. + +**Parameters** + +- `pathToProp` **string** dot-separated path to a property specified on the PageObject +- `options` **Object** + - `options.chainable` **Boolean** when this is true, an aliased + method returns the PageObject node on which the alias is defined, rather + than the PageObject node on which the aliased property is defined. + +**Examples** + +```javascript +import { create } from 'ember-cli-page-object'; +import { alias } from 'ember-cli-page-object/macros'; + +const page = create({ + submitButton: { + scope: '.submit-button' + }, + submit: alias('submitButton.click') +}); + +// calls `page.submitButton.click` +page.submit(); +``` + +```javascript +import { create } from 'ember-cli-page-object'; +import { alias } from 'ember-cli-page-object/macros'; + +const page = create({ + submitButton: { + scope: '.submit-button' + }, + isSubmitButtonVisible: alias('submitButton.isVisible') +}); + +// checks value of `page.submitButton.isVisible` +assert.ok(page.isSubmitButtonVisible); +``` + +```javascript +import { create } from 'ember-cli-page-object'; +import { alias } from 'ember-cli-page-object/macros'; + +const page = create({ + form: { + input: { + scope: 'input' + }, + submitButton: { + scope: '.submit-button' + } + }, + fillFormInput: alias('form.input.fillIn', { chainable: true }), + submitForm: alias('form.submitButton.click', { chainable: true }) +}); + +// executes `page.form.input.fillIn` then `page.form.submitButton.click` +// and causes both methods to return `page` (instead of `page.form.input` +// and `page.form.submitButton` respectively) so that the aliased methods +// can be chained off `page`. +page + .fillFormInput('foo') + .submitForm(); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/as.md b/docs/v1.13.x/api/as.md new file mode 100644 index 00000000..31c92e1e --- /dev/null +++ b/docs/v1.13.x/api/as.md @@ -0,0 +1,61 @@ +--- +layout: page +title: As +--- + +{% raw %} +### Methods + +- [as](#as) + +## as + +[addon/-private/properties/as.js:49-52](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/as.js#L49-L52 "Source code on GitHub") + +**Parameters** + +- `callback` **function** Function to be called with the current object as the parameter + +**Examples** + +```javascript +andThen(() => { + page.users(1).as(user => { + assert.equal(user.name, 'John'); + assert.equal(user.lastName, 'Doe'); + assert.equal(user.email, 'john@doe'); + }); + + page.users(2).as(user => { + assert.equal(user.name, 'John'); + assert.equal(user.lastName, 'Doe'); + assert.equal(user.email, 'john@doe'); + }); + + page.users(3).as(user => { + assert.equal(user.name, 'John'); + assert.equal(user.lastName, 'Doe'); + assert.equal(user.email, 'john@doe'); + }); +}); +``` + +```javascript +// Lorem ipsum dolor + +let page = create({ + scope: 'span', + foo: { + bar: { + scope: 'strong' + } + } +}); + +page.foo.bar.as(element => { + assert.equal(element.text, 'dolor'); +}); +``` + +Returns **object** this +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/attribute.md b/docs/v1.13.x/api/attribute.md new file mode 100644 index 00000000..103205e8 --- /dev/null +++ b/docs/v1.13.x/api/attribute.md @@ -0,0 +1,76 @@ +--- +layout: page +title: Attribute +--- + +{% raw %} +### Methods + +- [attribute](#attribute) + +## attribute + +[addon/-private/properties/attribute.js:70-90](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/attribute.js#L70-L90 "Source code on GitHub") + +**Parameters** + +- `attributeName` **string** Name of the attribute to get +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.resetScope` **boolean** Override parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.multiple` **boolean** If set, the function will return an array of values + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// + +const page = PageObject.create({ + inputPlaceholder: PageObject.attribute('placeholder', 'input') +}); + +assert.equal(page.inputPlaceholder, 'a value'); +``` + +```javascript +// +// + +const page = PageObject.create({ + inputPlaceholders: PageObject.attribute('placeholder', ':input', { multiple: true }) +}); + +assert.deepEqual(page.inputPlaceholders, ['a value', 'other value']); +``` + +```javascript +//
+//
+//
+ +const page = PageObject.create({ + inputPlaceholder: PageObject.attribute('placeholder', ':input', { scope: '.scope' }) +}); + +assert.equal(page.inputPlaceholder, 'a value'); +``` + +```javascript +//
+//
+//
+ +const page = PageObject.create({ + scope: 'scope', + inputPlaceholder: PageObject.attribute('placeholder', ':input') +}); + +assert.equal(page.inputPlaceholder, 'a value'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/click-on-text.md b/docs/v1.13.x/api/click-on-text.md new file mode 100644 index 00000000..f16cbc47 --- /dev/null +++ b/docs/v1.13.x/api/click-on-text.md @@ -0,0 +1,93 @@ +--- +layout: page +title: Click on-text +--- + +{% raw %} +### Methods + +- [clickOnText](#clickontext) + +## clickOnText + +[addon/-private/properties/click-on-text.js:81-101](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/click-on-text.js#L81-L101 "Source code on GitHub") + +Clicks on an element containing specified text. + +The element can either match a specified selector, +or be inside an element matching the specified selector. + +**Parameters** + +- `selector` **string** CSS selector of the element in which to look for text +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.visible` **boolean** Make the action to raise an error if the element is not visible + - `options.resetScope` **boolean** Override parent's scope + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +//
+// +// +//
+ +const page = PageObject.create({ + clickOnFieldset: PageObject.clickOnText('fieldset'), + clickOnButton: PageObject.clickOnText('button') +}); + +// queries the DOM with selector 'fieldset :contains("Lorem"):last' +page.clickOnFieldset('Lorem'); + +// queries the DOM with selector 'button:contains("Ipsum")' +page.clickOnButton('Ipsum'); +``` + +```javascript +//
+//
+// +// +//
+//
+ +const page = PageObject.create({ + clickOnFieldset: PageObject.clickOnText('fieldset', { scope: '.scope' }), + clickOnButton: PageObject.clickOnText('button', { scope: '.scope' }) +}); + +// queries the DOM with selector '.scope fieldset :contains("Lorem"):last' +page.clickOnFieldset('Lorem'); + +// queries the DOM with selector '.scope button:contains("Ipsum")' +page.clickOnButton('Ipsum'); +``` + +```javascript +//
+//
+// +// +//
+//
+ +const page = PageObject.create({ + scope: '.scope', + clickOnFieldset: PageObject.clickOnText('fieldset'), + clickOnButton: PageObject.clickOnText('button') +}); + +// queries the DOM with selector '.scope fieldset :contains("Lorem"):last' +page.clickOnFieldset('Lorem'); + +// queries the DOM with selector '.scope button:contains("Ipsum")' +page.clickOnButton('Ipsum'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/clickable.md b/docs/v1.13.x/api/clickable.md new file mode 100644 index 00000000..7722dbd0 --- /dev/null +++ b/docs/v1.13.x/api/clickable.md @@ -0,0 +1,72 @@ +--- +layout: page +title: Clickable +--- + +{% raw %} +### Methods + +- [clickable](#clickable) + +## clickable + +[addon/-private/properties/clickable.js:59-79](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/clickable.js#L59-L79 "Source code on GitHub") + +Clicks elements matched by a selector. + +**Parameters** + +- `selector` **string** CSS selector of the element to click +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.visible` **boolean** Make the action to raise an error if the element is not visible + - `options.resetScope` **boolean** Ignore parent scope + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// + +const page = PageObject.create({ + continue: clickable('button.continue') +}); + +// clicks on element with selector 'button.continue' +page.continue(); +``` + +```javascript +//
+//
+// + +const page = PageObject.create({ + continue: clickable('button.continue', { scope: '.scope' }) +}); + +// clicks on element with selector '.scope button.continue' +page.continue(); +``` + +```javascript +//
+//
+// + +const page = PageObject.create({ + scope: '.scope', + continue: clickable('button.continue') +}); + +// clicks on element with selector '.scope button.continue' +page.continue(); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/collection.md b/docs/v1.13.x/api/collection.md new file mode 100644 index 00000000..7e581341 --- /dev/null +++ b/docs/v1.13.x/api/collection.md @@ -0,0 +1,123 @@ +--- +layout: page +title: Collection +--- + +{% raw %} +### Methods + +- [collection](#collection) + +## collection + +[addon/-private/properties/collection.js:215-242](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/collection.js#L215-L242 "Source code on GitHub") + +**Parameters** + +- `definition` **Object** Collection definition + - `definition.scope` **string** Nests provided scope within parent's scope + - `definition.resetScope` **boolean** Override parent's scope + - `definition.itemScope` **string** CSS selector + - `definition.item` **Object** Item definition + +**Examples** + +```javascript +// +// +// +// +// +// +// +// +// +// +//
List of users
Mary +// Watson
John +// Doe
+ +const page = PageObject.create({ + users: collection({ + itemScope: 'table tr', + + item: { + firstName: text('td', { at: 0 }), + lastName: text('td', { at: 1 }) + }, + + caption: text('caption') + }) +}); + +assert.equal(page.users().count, 2); +assert.equal(page.users().caption, 'List of users'); +assert.equal(page.users(1).firstName, 'John'); +assert.equal(page.users(1).lastName, 'Doe'); +``` + +```javascript +//
+// +// +// +// +// +// +// +// +// +//
Mary +// Watson
John +// Doe
+//
+ +//
+// +//
+//
+ +const page = PageObject.create({ + users: collection({ + scope: '.admins', + + itemScope: 'table tr', + + item: { + firstName: text('td', { at: 0 }), + lastName: text('td', { at: 1 }) + } + }) +}); + +assert.equal(page.users().count, 2); +``` + +```javascript +// +// +// +// +// +// +// +//
User Index
Doe
+ +const page = PageObject.create({ + users: PageObject.collection({ + scope: 'table', + itemScope: 'tr', + + item: { + firstName: text('td', { at: 0 }) + }, + + caption: PageObject.text('caption') + }) +}); + +assert.equal(page.users().caption, 'User Index'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/contains.md b/docs/v1.13.x/api/contains.md new file mode 100644 index 00000000..b2a5b451 --- /dev/null +++ b/docs/v1.13.x/api/contains.md @@ -0,0 +1,94 @@ +--- +layout: page +title: Contains +--- + +{% raw %} +### Methods + +- [contains](#contains) + +## contains + +[addon/-private/properties/contains.js:84-103](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/contains.js#L84-L103 "Source code on GitHub") + +Returns a boolean representing whether an element or a set of elements contains the specified text. + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector contain the subtext + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanContains: PageObject.contains('span') +}); + +assert.ok(page.spanContains('ipsum')); +``` + +```javascript +// lorem +// ipsum +// dolor + +const page = PageObject.create({ + spansContain: PageObject.contains('span', { multiple: true }) +}); + +// not all spans contain 'lorem' +assert.notOk(page.spansContain('lorem')); +``` + +```javascript +// super text +// regular text + +const page = PageObject.create({ + spansContain: PageObject.contains('span', { multiple: true }) +}); + +// all spans contain 'text' +assert.ok(page.spanContains('text')); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + spanContains: PageObject.contains('span', { scope: '.scope' }) +}); + +assert.notOk(page.spanContains('lorem')); +assert.ok(page.spanContains('ipsum')); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + scope: '.scope', + + spanContains: PageObject.contains('span') +}); + +assert.notOk(page.spanContains('lorem')); +assert.ok(page.spanContains('ipsum')); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/count.md b/docs/v1.13.x/api/count.md new file mode 100644 index 00000000..88b592b8 --- /dev/null +++ b/docs/v1.13.x/api/count.md @@ -0,0 +1,83 @@ +--- +layout: page +title: Count +--- + +{% raw %} +### Methods + +- [count](#count) + +## count + +[addon/-private/properties/count.js:74-89](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/count.js#L74-L89 "Source code on GitHub") + +**Parameters** + +- `selector` **string** CSS selector of the element or elements to check +- `options` **Object** Additional options + - `options.scope` **string** Add scope + - `options.resetScope` **boolean** Ignore parent scope + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// 1 +// 2 + +const page = PageObject.create({ + spanCount: PageObject.count('span') +}); + +assert.equal(page.spanCount, 2); +``` + +```javascript +//
Text
+ +const page = PageObject.create({ + spanCount: PageObject.count('span') +}); + +assert.equal(page.spanCount, 0); +``` + +```javascript +//
+//
+ +const page = PageObject.create({ + spanCount: PageObject.count('span', { scope: '.scope' }) +}); + +assert.equal(page.spanCount, 2) +``` + +```javascript +//
+//
+ +const page = PageObject.create({ + scope: '.scope', + spanCount: PageObject.count('span') +}); + +assert.equal(page.spanCount, 2) +``` + +```javascript +//
+//
+ +const page = PageObject.create({ + scope: '.scope', + spanCount: PageObject.count('span', { resetScope: true }) +}); + +assert.equal(page.spanCount, 1); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/create.md b/docs/v1.13.x/api/create.md new file mode 100644 index 00000000..b7b8d3eb --- /dev/null +++ b/docs/v1.13.x/api/create.md @@ -0,0 +1,112 @@ +--- +layout: page +title: Create +--- + +{% raw %} +### Methods + +- [create](#create) + +## create + +[addon/-private/create.js:99-138](https://github.com/san650/ember-cli-page-object/blob/c521335ffba9955a6acaf1006ed503cbb61ba72d/addon/-private/create.js#L99-L138 "Source code on GitHub") + +Creates a new PageObject. + +By default, the resulting PageObject will respond to: + +* [click](/docs/v1.12.x/api/clickable) +* [clickOn](/docs/v1.12.x/api/click-on-text) +* [contains](/docs/v1.12.x/api/contains) +* [fillIn](/docs/v1.12.x/api/fillable) +* [isPresent](/docs/v1.12.x/api/is-present) +* [isVisible](/docs/v1.12.x/api/is-visible) +* [isHidden](/docs/v1.12.x/api/is-hidden) +* [select](/docs/v1.12.x/api/selectable) +* [text](/docs/v1.12.x/api/text) + +`definition` can include a key `context`, which is an +optional integration test `this` context. + +If a context is passed, it is used by actions, queries, etc., +as the `this` in `this.$()`. + +If no context is passed, the global Ember acceptence test +helpers are used. + +**Parameters** + +- `definition` **Object** PageObject definition + - `definition.context` **[Object]** A test's `this` context +- `options` **Object** [private] Ceibo options. Do not use! +- `definitionOrUrl` +- `definitionOrOptions` +- `optionsOrNothing` + +**Examples** + +```javascript +//
My title
+ +import PageObject, { text } from 'ember-cli-page-object'; + +const page = PageObject.create({ + title: text('.title') +}); + +assert.equal(page.title, 'My title'); +``` + +```javascript +//
+// My super text +// +//
+ +const page = PageObject.create({ + scope: '#my-page' +}); + +assert.equal(page.text, 'My super text'); +assert.ok(page.contains('super')); +assert.ok(page.isPresent); +assert.ok(page.isVisible); +assert.notOk(page.isHidden); +assert.equal(page.value, 'my input value'); + +// clicks div#my-page +page.click(); + +// clicks button +page.clickOn('Press Me'); + +// fills an input +page.fillIn('name', 'John Doe'); + +// selects an option +page.select('country', 'Uruguay'); +``` + +```javascript +Defining path + +const usersPage = PageObject.create('/users'); + +// visits user page +usersPage.visit(); + +const userTasksPage = PageObject.create('/users/tasks', { + tasks: collection({ + itemScope: '.tasks li', + item: {} + }); +}); + +// get user's tasks +userTasksPage.visit(); +userTasksPage.tasks().count +``` + +Returns **PageObject** +{% endraw %} diff --git a/docs/v1.13.x/api/fillable.md b/docs/v1.13.x/api/fillable.md new file mode 100644 index 00000000..025dcfda --- /dev/null +++ b/docs/v1.13.x/api/fillable.md @@ -0,0 +1,127 @@ +--- +layout: page +title: Fillable +--- + +{% raw %} +### Methods + +- [fillable](#fillable) +- [selectable](#selectable) + +## fillable + +[addon/-private/properties/fillable.js:110-151](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/fillable.js#L110-L151 "Source code on GitHub") + +Fills in an input matched by a selector. + +**Parameters** + +- `selector` **string** CSS selector of the element to look for text +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// + +const page = PageObject.create({ + fillIn: PageObject.fillable('input') +}); + +// result: +page.fillIn('John Doe'); +``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + fillInName: PageObject.fillable('input', { scope: '.name' }) +}); + +page.fillInName('John Doe'); + +// result +//
+// +//
+``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + scope: 'name', + fillInName: PageObject.fillable('input') +}); + +page.fillInName('John Doe'); + +// result +//
+// +//
+``` + +```javascript +Filling different inputs with the same property + +// +// +// +// +// +//
+ +const page = create({ + fillIn: fillable('input, textarea, [contenteditable]') +}); + +page + .fillIn('name', 'Doe') + .fillIn('lastname', 'Doe') + .fillIn('email', 'john@doe') + .fillIn('address', 'A street') + .fillIn('phone', '555-000') + .fillIn('bio', 'The story of John Doe'); +``` + +Returns **Descriptor** + +## selectable + +[addon/-private/properties/fillable.js:110-151](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/fillable.js#L110-L151 "Source code on GitHub") + +Alias for `fillable`, which works for inputs, HTML select menus, and +contenteditable elements. + +[See `fillable` for usage examples.](#fillable) + +**Parameters** + +- `selector` **string** CSS selector of the element to look for text +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/getter.md b/docs/v1.13.x/api/getter.md new file mode 100644 index 00000000..e9128093 --- /dev/null +++ b/docs/v1.13.x/api/getter.md @@ -0,0 +1,55 @@ +--- +layout: page +title: Getter +--- + +{% raw %} +### Methods + +- [getter](#getter) + +## getter + +[addon/-private/properties/getter.js:46-58](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/getter.js#L46-L58 "Source code on GitHub") + +Creates a Descriptor whose value is determined by the passed-in function. +The passed-in function must not be bound and must not be an arrow function, +as this would prevent it from running with the correct context. + +**Parameters** + +- `fn` **Function** determines what value is returned when the Descriptor is accessed + +**Examples** + +```javascript +// +// + +import { create } from 'ember-cli-page-object'; +import { getter } from 'ember-cli-page-object/macros'; + +const page = create({ + inputValue: value('input'), + isSubmitButtonDisabled: property('disabled', 'button'), + + // with the `getter` macro + isFormEmpty: getter(function() { + return !this.inputValue && this.isSubmitButtonDisabled; + }), + + // without the `getter` macro + _isFormEmpty: { + isDescriptor: true, + get() { + return !this.inputValue && this.isSubmitButtonDisabled; + } + } +}); + +// checks the value returned by the function passed into `getter` +assert.ok(page.isFormEmpty); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/has-class.md b/docs/v1.13.x/api/has-class.md new file mode 100644 index 00000000..55cbbb73 --- /dev/null +++ b/docs/v1.13.x/api/has-class.md @@ -0,0 +1,95 @@ +--- +layout: page +title: Has class +--- + +{% raw %} +### Methods + +- [hasClass](#hasclass) + +## hasClass + +[addon/-private/properties/has-class.js:85-102](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/has-class.js#L85-L102 "Source code on GitHub") + +Validates if an element or a set of elements have a given CSS class. + +**Parameters** + +- `cssClass` **string** CSS class to be validated +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector have the CSS class + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Message! + +const page = PageObject.create({ + messageIsSuccess: PageObject.hasClass('success', 'span') +}); + +assert.ok(page.messageIsSuccess); +``` + +```javascript +// +// + +const page = PageObject.create({ + messagesAreSuccessful: PageObject.hasClass('success', 'span', { multiple: true }) +}); + +assert.notOk(page.messagesAreSuccessful); +``` + +```javascript +// +// + +const page = PageObject.create({ + messagesAreSuccessful: PageObject.hasClass('success', 'span', { multiple: true }) +}); + +assert.ok(page.messagesAreSuccessful); +``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + spanHasClass: PageObject.hasClass('ipsum', 'span', { scope: '.scope' }) +}); + +assert.ok(page.spanHasClass); +``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + scope: '.scope', + spanHasClass: PageObject.hasClass('ipsum', 'span') +}); + +assert.ok(page.spanHasClass); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/is-hidden.md b/docs/v1.13.x/api/is-hidden.md new file mode 100644 index 00000000..df0a011b --- /dev/null +++ b/docs/v1.13.x/api/is-hidden.md @@ -0,0 +1,101 @@ +--- +layout: page +title: Is hidden +--- + +{% raw %} +### Methods + +- [isHidden](#ishidden) + +## isHidden + +[addon/-private/properties/is-hidden.js:90-107](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/is-hidden.js#L90-L107 "Source code on GitHub") + +Validates if an element or set of elements is hidden or does not exist in the DOM. + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector are hidden + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsHidden: PageObject.isHidden('span') +}); + +assert.ok(page.spanIsHidden); +``` + +```javascript +// ipsum +// dolor + +const page = create({ + spansAreHidden: PageObject.isHidden('span', { multiple: true }) +}); + +// not all spans are hidden +assert.notOk(page.spansAreHidden); +``` + +```javascript +// dolor +// dolor + +const page = create({ + spansAreHidden: PageObject.isHidden('span', { multiple: true }) +}); + +// all spans are hidden +assert.ok(page.spansAreHidden); +``` + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsHidden: PageObject.isHidden('span') +}); + +// returns true when element doesn't exist in DOM +assert.ok(page.spanIsHidden); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + scopedSpanIsHidden: PageObject.isHidden('span', { scope: '.scope' }) +}); + +assert.ok(page.scopedSpanIsHidden); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + scope: '.scope', + scopedSpanIsHidden: PageObject.isHidden('span') +}); + +assert.ok(page.scopedSpanIsHidden); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/is-present.md b/docs/v1.13.x/api/is-present.md new file mode 100644 index 00000000..d7b4c29c --- /dev/null +++ b/docs/v1.13.x/api/is-present.md @@ -0,0 +1,87 @@ +--- +layout: page +title: Is present +--- + +{% raw %} +### Methods + +- [isPresent](#ispresent) + +## isPresent + +[addon/-private/properties/is-present.js:74-81](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/is-present.js#L74-L81 "Source code on GitHub") + +Validates if any element matching the target selector is rendered in the DOM. + +`isPresent` vs. `isVisible`: + +- Both validate that an element matching the target selector can be found in the DOM +- `isVisible` additionally validates that all matching elements are visible + +Some uses cases for `isPresent` over `isVisible`: + +- To check for the presence of a tag that is never visible in the DOM (e.g., ). +- To validate that, even though an element may not currently be visible, it is still in the DOM. +- To validate that an element has not merely been hidden but has in fact been removed from the DOM. + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector are visible + - `options.testContainer` **string** Context where to search elements in the DOM + +**Examples** + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsPresent: PageObject.isPresent('span') +}); + +assert.ok(page.spanIsPresent); +``` + +```javascript +// ipsum +// dolor + +const page = PageObject.create({ + spanIsPresent: PageObject.isPresent('span', { multiple: true }) +}); + +assert.ok(page.spanIsPresent); +``` + +```javascript +// +// +// + +const page = PageObject.create({ + notIndexed: PageObject.isPresent(`meta[name='robots'][content='noindex']`, { + testContainer: 'head' + }) +}); + +assert.ok(page.notIndexed); +``` + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsPresent: PageObject.isPresent('span') +}); + +// returns false when element doesn't exist in DOM +assert.notOk(page.spanIsPresent); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/is-visible.md b/docs/v1.13.x/api/is-visible.md new file mode 100644 index 00000000..6d29525c --- /dev/null +++ b/docs/v1.13.x/api/is-visible.md @@ -0,0 +1,107 @@ +--- +layout: page +title: Is visible +--- + +{% raw %} +### Methods + +- [isVisible](#isvisible) + +## isVisible + +[addon/-private/properties/is-visible.js:96-117](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/is-visible.js#L96-L117 "Source code on GitHub") + +Validates if an element or set of elements are visible. + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector are visible + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsVisible: PageObject.isVisible('span') +}); + +assert.ok(page.spanIsVisible); +``` + +```javascript +// ipsum +// dolor + +const page = PageObject.create({ + spansAreVisible: PageObject.isVisible('span', { multiple: true }) +}); + +// not all spans are visible +assert.notOk(page.spansAreVisible); +``` + +```javascript +// ipsum +// dolor + +const page = PageObject.create({ + spansAreVisible: PageObject.isVisible('span', { multiple: true }) +}); + +// all spans are visible +assert.ok(page.spansAreVisible); +``` + +```javascript +// Lorem ipsum + +const page = PageObject.create({ + spanIsVisible: PageObject.isVisible('span') +}); + +// returns false when element doesn't exist in DOM +assert.notOk(page.spanIsVisible); +``` + +```javascript +//
+// lorem +//
+//
+// ipsum +//
+ +const page = PageObject.create({ + spanIsVisible: PageObject.isVisible('span', { scope: '.scope' }) +}); + +assert.ok(page.spanIsVisible); +``` + +```javascript +//
+// lorem +//
+//
+// ipsum +//
+ +const page = PageObject.create({ + scope: '.scope', + spanIsVisible: PageObject.isVisible('span') +}); + +assert.ok(page.spanIsVisible); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/is.md b/docs/v1.13.x/api/is.md new file mode 100644 index 00000000..5c660c75 --- /dev/null +++ b/docs/v1.13.x/api/is.md @@ -0,0 +1,51 @@ +--- +layout: page +title: Is +--- + +{% raw %} +### Methods + +- [is](#is) + +## is + +[addon/-private/properties/is.js:45-62](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/is.js#L45-L62 "Source code on GitHub") + +**Parameters** + +- `testSelector` **string** CSS selector to test +- `targetSelector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.resetScope` **boolean** Override parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.multiple` **boolean** If set, the function will return an array of values + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// +// + +const page = PageObject.create({ + areInputsChecked: is(':checked', 'input', { multiple: true }) +}); + +assert.equal(page.areInputsChecked, true, 'Inputs are checked'); +``` + +```javascript +// + +const page = PageObject.create({ + isToggleButtonActive: is('.active:disabled', '.toggle-button') +}); + +assert.equal(page.isToggleButtonActive, true, 'Button is active'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/not-has-class.md b/docs/v1.13.x/api/not-has-class.md new file mode 100644 index 00000000..a83f5639 --- /dev/null +++ b/docs/v1.13.x/api/not-has-class.md @@ -0,0 +1,95 @@ +--- +layout: page +title: Not has-class +--- + +{% raw %} +### Methods + +- [notHasClass](#nothasclass) + +## notHasClass + +[addon/-private/properties/not-has-class.js:89-106](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/not-has-class.js#L89-L106 "Source code on GitHub") + +**Parameters** + +- `cssClass` **string** CSS class to be validated +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Check if all elements matched by selector don't have the CSS class + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Message! + +const page = PageObject.create({ + messageIsSuccess: PageObject.notHasClass('error', 'span') +}); + +assert.ok(page.messageIsSuccess); +``` + +```javascript +// +// + +const page = PageObject.create({ + messagesAreSuccessful: PageObject.notHasClass('error', 'span', { multiple: true }) +}); + +// one span has error class +assert.notOk(page.messagesAreSuccessful); +``` + +```javascript +// +// + +const page = PageObject.create({ + messagesAreSuccessful: PageObject.notHasClass('error', 'span', { multiple: true }) +}); + +// no spans have error class +assert.ok(page.messagesAreSuccessful); +``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + spanNotHasClass: PageObject.notHasClass('lorem', 'span', { scope: '.scope' }) +}); + +assert.ok(page.spanNotHasClass); +``` + +```javascript +//
+// +//
+//
+// +//
+ +const page = PageObject.create({ + scope: '.scope', + spanNotHasClass: PageObject.notHasClass('lorem', 'span') +}); + +assert.ok(page.spanNotHasClass); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/property.md b/docs/v1.13.x/api/property.md new file mode 100644 index 00000000..82923619 --- /dev/null +++ b/docs/v1.13.x/api/property.md @@ -0,0 +1,62 @@ +--- +layout: page +title: Property +--- + +{% raw %} +### Methods + +- [property](#property) + +## property + +[addon/-private/properties/property.js:56-76](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/property.js#L56-L76 "Source code on GitHub") + +**Parameters** + +- `propertyName` **string** Name of the property to get +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.resetScope` **boolean** Override parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.multiple` **boolean** If set, the function will return an array of values +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// + +const page = PageObject.create({ + isChecked: PageObject.property('checked', 'input') +}); + +assert.ok(page.isChecked); +``` + +```javascript +// +// + +const page = PageObject.create({ + inputsChecked: PageObject.property('checked', 'input', { multiple: true }) +}); + +assert.deepEqual(page.inputsChecked, [true, false]); +``` + +```javascript +//
+//
+//
+ +const page = PageObject.create({ + isChecked: PageObject.property('checked', 'input', { scope: '.scope' }) +}); + +assert.ok(page.isChecked); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/text.md b/docs/v1.13.x/api/text.md new file mode 100644 index 00000000..037c6273 --- /dev/null +++ b/docs/v1.13.x/api/text.md @@ -0,0 +1,94 @@ +--- +layout: page +title: Text +--- + +{% raw %} +### Methods + +- [text](#text) + +## text + +[addon/-private/properties/text.js:92-112](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/text.js#L92-L112 "Source code on GitHub") + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Override parent's scope + - `options.multiple` **boolean** Return an array of values + - `options.normalize` **boolean** Set to `false` to avoid text normalization + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// Hello world! + +const page = PageObject.create({ + text: PageObject.text('span') +}); + +assert.equal(page.text, 'world!'); +``` + +```javascript +// lorem +// ipsum +// dolor + +const page = PageObject.create({ + texts: PageObject.text('span', { multiple: true }) +}); + +assert.deepEqual(page.texts, ['lorem', 'ipsum', 'dolor']); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + text: PageObject.text('span', { scope: '.scope' }) +}); + +assert.equal(page.text, 'ipsum'); +``` + +```javascript +//
lorem
+//
ipsum
+//
dolor
+ +const page = PageObject.create({ + scope: '.scope', + text: PageObject.text('span') +}); + +// returns 'ipsum' +assert.equal(page.text, 'ipsum'); +``` + +```javascript +//
lorem
+//
+// ipsum +//
+//
dolor
+ +const page = PageObject.create({ + scope: '.scope', + text: PageObject.text('span', { normalize: false }) +}); + +// returns 'ipsum' +assert.equal(page.text, '\n ipsum\n'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/triggerable.md b/docs/v1.13.x/api/triggerable.md new file mode 100644 index 00000000..b60dadae --- /dev/null +++ b/docs/v1.13.x/api/triggerable.md @@ -0,0 +1,97 @@ +--- +layout: page +title: Triggerable +--- + +{% raw %} +### Methods + +- [triggerable](#triggerable) + +## triggerable + +[addon/-private/properties/triggerable.js:85-107](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/triggerable.js#L85-L107 "Source code on GitHub") + +Triggers event on element matched by selector. + +**Parameters** + +- `event` **string** Event to be triggered +- `selector` **string** CSS selector of the element on which the event will be triggered +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.resetScope` **boolean** Ignore parent scope + - `options.testContainer` **string** Context where to search elements in the DOM + - `options.eventProperties` **string** Event properties that will be passed to trigger function +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// +// + +const page = PageObject.create({ + focus: triggerable('focus', '.name') +}); + +// focuses on element with selector '.name' +page.focus(); +``` + +```javascript +// +// + +const page = PageObject.create({ + enter: triggerable('keypress', '.name', { eventProperties: { keyCode: 13 } }) +}); + +// triggers keypress using enter key on element with selector '.name' +page.enter(); +``` + +```javascript +// +// + +const page = PageObject.create({ + keydown: triggerable('keypress', '.name') +}); + +// triggers keypress using enter key on element with selector '.name' +page.keydown({ which: 13 }); +``` + +```javascript +//
+// +//
+// + +const page = PageObject.create({ + focus: triggerable('focus', '.name', { scope: '.scope' }) +}); + +// focuses on element with selector '.scope .name' +page.focus(); +``` + +```javascript +//
+// +//
+// + +const page = PageObject.create({ + scope: '.scope', + focus: triggerable('focus', '.name') +}); + +// focuses on element with selector '.scope .name' +page.focus(); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/value.md b/docs/v1.13.x/api/value.md new file mode 100644 index 00000000..2c456daa --- /dev/null +++ b/docs/v1.13.x/api/value.md @@ -0,0 +1,83 @@ +--- +layout: page +title: Value +--- + +{% raw %} +### Methods + +- [value](#value) + +## value + +[addon/-private/properties/value.js:79-103](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/value.js#L79-L103 "Source code on GitHub") + +**Parameters** + +- `selector` **string** CSS selector of the element to check +- `options` **Object** Additional options + - `options.scope` **string** Nests provided scope within parent's scope + - `options.resetScope` **boolean** Override parent's scope + - `options.at` **number** Reduce the set of matched elements to the one at the specified index + - `options.multiple` **boolean** If set, the function will return an array of values + - `options.testContainer` **string** Context where to search elements in the DOM +- `userOptions` (optional, default `{}`) + +**Examples** + +```javascript +// + +const page = PageObject.create({ + value: PageObject.value('input') +}); + +assert.equal(page.value, 'Lorem ipsum'); +``` + +```javascript +//
Lorem ipsum
+ +const page = PageObject.create({ + value: PageObject.value('[contenteditable]') +}); + +assert.equal(page.value, 'Lorem ipsum'); +``` + +```javascript +// +// + +const page = PageObject.create({ + value: PageObject.value('input', { multiple: true }) +}); + +assert.deepEqual(page.value, ['lorem', 'ipsum']); +``` + +```javascript +//
+//
+ +const page = PageObject.create({ + value: PageObject.value('input', { scope: '.scope' }) +}); + +assert.equal(page.value, 'ipsum'); +``` + +```javascript +//
+//
+ +const page = PageObject.create({ + scope: '.scope', + value: PageObject.value('input') +}); + +assert.equal(page.value, 'ipsum'); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/api/visitable.md b/docs/v1.13.x/api/visitable.md new file mode 100644 index 00000000..f36f0e16 --- /dev/null +++ b/docs/v1.13.x/api/visitable.md @@ -0,0 +1,58 @@ +--- +layout: page +title: Visitable +--- + +{% raw %} +### Methods + +- [visitable](#visitable) + +## visitable + +[addon/-private/properties/visitable.js:85-104](https://github.com/san650/ember-cli-page-object/blob/f70ce5d253619a25948ed1de7c34cb3f3978c953/addon/-private/properties/visitable.js#L85-L104 "Source code on GitHub") + +**Parameters** + +- `path` **string** Full path of the route to visit + +**Examples** + +```javascript +const page = PageObject.create({ + visit: PageObject.visitable('/users') +}); + +// visits '/users' +page.visit(); +``` + +```javascript +const page = PageObject.create({ + visit: PageObject.visitable('/users/:user_id') +}); + +// visits '/users/10' +page.visit({ user_id: 10 }); +``` + +```javascript +const page = PageObject.create({ + visit: PageObject.visitable('/users') +}); + +// visits '/users?name=john' +page.visit({ name: 'john' }); +``` + +```javascript +const page = PageObject.create({ + visit: PageObject.visitable('/users/:user_id') +}); + +// visits '/users/1?name=john' +page.visit({ user_id: 1, name: 'john' }); +``` + +Returns **Descriptor** +{% endraw %} \ No newline at end of file diff --git a/docs/v1.13.x/components.md b/docs/v1.13.x/components.md new file mode 100644 index 00000000..e8588d18 --- /dev/null +++ b/docs/v1.13.x/components.md @@ -0,0 +1,250 @@ +--- +layout: page +title: Components +--- + +Group attributes and create new ones + +* [Components](#components) +* [Default attributes](#default-attributes) +* [Custom helper](#custom-helper) +* [Scopes](#scopes) + +## Components + +Components let you group attributes together, they are just plain objects with attributes on it. You can even define these objects in different files and reuse them in multiple places. Components can define a scope. + +__Example__ + +```html +

New user

+
+ + + +
+``` + +```js +const { visitable, text, fillable, clickable } = PageObject; + +var page = PageObject.create({ + visit: visitable('/user/create'), + title: text('h1'), + + form: { + scope: '.awesome-form', + + firstName: fillable('#firstName'), + lastName: fillable('#lastName'), + submit: clickable('button') + } +}); + +page + .visit() + .form + .firstName('John') + .lastName('Doe') + .submit(); + +andThen(function() { + // assert something +}); +``` + +## Default attributes + +By default, all components define some handy attributes and methods without being explicitly declared. + +* [click](/docs/v1.8.x/api/clickable) +* [clickOn](/docs/v1.8.x/api/click-on-text) +* [contains](/docs/v1.8.x/api/contains) +* [fillIn](/docs/v1.8.x/api/fillable) +* [isVisible](/docs/v1.8.x/api/is-visible) +* [isHidden](/docs/v1.8.x/api/is-hidden) +* [select](/docs/v1.8.x/api/selectable) +* [text](/docs/v1.8.x/api/text) +* [value](/docs/v1.8.x/api/value) + + + +__Example__ + +Suppose you have a modal dialog + +```html +