diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 99a4eeeb9..ebec574b9 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -8,6 +8,11 @@ on: branches: - master +env: + CI: true + # Force terminal colors. @see https://www.npmjs.com/package/colors + FORCE_COLOR: 1 + jobs: build: @@ -26,8 +31,7 @@ jobs: - name: install required packages run: | sudo apt-get update - sudo apt-get install libgbm-dev libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libxslt1.1 - sudo apt-get install xvfb + sudo apt-get install libgbm1 libgbm-dev libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libxslt1.1 sudo apt-get install php - name: npm install run: | @@ -35,8 +39,8 @@ jobs: - name: start a server run: "php -S 127.0.0.1:8000 -t test/data/app &" - name: run chromium tests - run: " ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" + run: "./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" - name: run firefox tests - run: "BROWSER=firefox ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" + run: "BROWSER=firefox node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" - name: run webkit tests - run: "BROWSER=webkit ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" + run: "BROWSER=webkit node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug" diff --git a/CHANGELOG.md b/CHANGELOG.md index f12d69ee4..92ac8aa0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,80 @@ +## 2.6.0 + +* **[Playwright] Updated to Playwright 0.12** by @Georgegriff. + +Upgrade playwright to ^0.12: + +``` +npm i playwright@^0.12 --save +``` + +[Notable changes](https://github.com/microsoft/playwright/releases/tag/v0.12.0): + * Fixed opening two browsers on start + * `executeScript` - passed function now accepts only one argument. Pass in objects or arrays if you need multtple arguments: +```js +// Old style, does not work anymore: +I.executeScript((x, y) => x + y, x, y); +// New style, passing an object: +I.executeScript(({x, y}) => x + y, {x, y}); +``` + * `click` - automatically waits for element to become clickable (visible, not animated) and waits for navigation. + * `clickLink` - deprecated + * `waitForClickable` - deprecated + * Added support for custom locators. See #2277 + * Introduced [device emulation](/playwright/#device-emulation): + * globally via `emulate` config option + * per session + +**[WebDriver] Updated to webdriverio v6** by @PeterNgTr. + +Read [release notes](https://webdriver.io/blog/2020/03/26/webdriverio-v6-released.html), then +upgrade webdriverio to ^6.0: + +``` +npm i webdriverio@^6.0 --save +``` +*(webdriverio v5 support is deprecated and will be removed in CodeceptJS 3.0)* + +[WebDriver] Introduced [Shadow DOM support](/shadow) by @gkushang + +```js +I.click({ shadow: ['my-app', 'recipe-hello', 'button'] }); +``` + +* **Fixed parallel execution of `run-workers` for Gherkin** scenarios by @koushikmohan1996 +* [MockRequest] Updated and **moved to [standalone package](https://github.com/codecept-js/mock-request)**: + * full support for record/replay mode for Puppeteer + * added `mockServer` method to use flexible PollyJS API to define mocks + * fixed stale browser screen in record mode. +* [Playwright] Added support on for `screenshotOnFail` plugin by @amonkc +* Gherkin improvement: setting different tags per examples. See #2208 by @acuper +* [TestCafe] Updated `click` to take first visible element. Fixes #2226 by @theTainted +* [Puppeteer][WebDriver] Updated `waitForClickable` method to check for element overlapping. See #2261 by @PiQx +* [Puppeteer] Dropped `puppeteer-firefox` support, as Puppeteer supports Firefox natively. +* [REST] Rrespect Content-Type header. See #2262 by @pmarshall-legacy +* [allure plugin] Fixes BeforeSuite failures in allure reports. See #2248 by @Georgegriff +* [WebDriver][Puppeteer][Playwright] A screenshot of for an active session is saved in multi-session mode. See #2253 by @ChexWarrior +* Fixed `--profile` option by @pablopaul. Profile value to be passed into `run-multiple` and `run-workers`: + +``` +npx codecept run-workers 2 --profile firefox +``` + +Value is available at `process.env.profile` (previously `process.profile`). See #2302. Fixes #1968 #1315 + +* [commentStep Plugin introduced](/plugins#commentstep). Allows to annotate logical parts of a test: + +```js +__`Given`; +I.amOnPage('/profile') + +__`When`; +I.click('Logout'); + +__`Then`; +I.see('You are logged out'); +``` + ## 2.5.0 * **Experimental: [Playwright](/playwright) helper introduced**. diff --git a/docs/basics.md b/docs/basics.md index d3cb25dca..9e02721fe 100644 --- a/docs/basics.md +++ b/docs/basics.md @@ -622,7 +622,7 @@ within('.js-signup-form', () => { I.see('There were problems creating your account.'); ``` -> ⚠ `within` can cause problems when used incorrectly. If you see a weired behavior of a test try to refactor it to not use `within`. It is recommended to keep within for simplest cases when possible. +> ⚠ `within` can cause problems when used incorrectly. If you see a weird behavior of a test try to refactor it to not use `within`. It is recommended to keep within for simplest cases when possible. `within` can also work with IFrames. A special `frame` locator is required to locate the iframe and get into its context. diff --git a/docs/changelog.md b/docs/changelog.md index 8d6800087..b040ec2cf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,6 +7,25 @@ layout: Section # Releases +## 2.5.0 + +* **Experimental: [Playwright](/playwright) helper introduced**. + +> [Playwright](https://github.com/microsoft/playwright/) is an alternative to Puppeteer which works very similarly to it but adds cross-browser support with Firefox and Webkit. Until v1.0 Playwright API is not stable but we introduce it to CodeceptJS so you could try it. + +* **[Puppeteer]** Fixed basic auth support when running in multiple sessions. See [#2178](https://github.com/Codeception/CodeceptJS/issues/2178) by **[ian-bartholomew](https://github.com/ian-bartholomew)** +* **[Puppeteer]** Fixed `waitForText` when there is no `body` element on page (redirect). See [#2181](https://github.com/Codeception/CodeceptJS/issues/2181) by **[Vorobeyko](https://github.com/Vorobeyko)** +* [Selenoid plugin] Fixed overriding current capabilities by adding deepMerge. Fixes [#2183](https://github.com/Codeception/CodeceptJS/issues/2183) by **[koushikmohan1996](https://github.com/koushikmohan1996)** +* Added types for `Scenario.todo` by **[Vorobeyko](https://github.com/Vorobeyko)** +* Added types for Mocha by **[Vorobeyko](https://github.com/Vorobeyko)**. Fixed typing conflicts with Jest +* **[FileSystem]** Added methods by **[nitschSB](https://github.com/nitschSB)** + * `waitForFile` + * `seeFileContentsEqualReferenceFile` +* Added `--colors` option to `run` and `run-multiple` so you force colored output in dockerized environment. See [#2189](https://github.com/Codeception/CodeceptJS/issues/2189) by **[mirao](https://github.com/mirao)** +* **[WebDriver]** Added `type` command to enter value without focusing on a field. See [#2198](https://github.com/Codeception/CodeceptJS/issues/2198) by **[xMutaGenx](https://github.com/xMutaGenx)** +* Fixed `codeceptjs gt` command to respect config pattern for tests. See [#2200](https://github.com/Codeception/CodeceptJS/issues/2200) and [#2204](https://github.com/Codeception/CodeceptJS/issues/2204) by **[matheo](https://github.com/matheo)** + + ## 2.4.3 * Hotfix for interactive pause diff --git a/docs/configuration.md b/docs/configuration.md index f8edcaa58..17940cafe 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -118,7 +118,7 @@ exports.config = { ## Profile -Using values from `process.profile` you can change the config dynamically. +Using `process.env.profile` you can change the config dynamically. It provides value of `--profile` option passed to runner. Use its value to change config value on the fly. @@ -134,7 +134,7 @@ exports.config = { WebDriver: { url: 'http://localhost:3000', // load value from `profile` - browser: process.profile || 'firefox' + browser: process.env.profile || 'firefox' } } diff --git a/docs/custom-helpers.md b/docs/custom-helpers.md index 430215cd4..00e9dc88b 100644 --- a/docs/custom-helpers.md +++ b/docs/custom-helpers.md @@ -3,6 +3,7 @@ permalink: /helpers title: Custom Helpers --- +# Extending CodeceptJS with Custom Helopers Helpers is a core concept of CodeceptJS. Helper is a wrapper on top of various libraries providing unified interface around them. @@ -168,6 +169,50 @@ class MyHelper extends Helper { module.exports = MyHelper; ``` +## Accessing Elements + +WebDriver, Puppeteer, Playwright, and Protractor drivers provide API for web elements. +However, CodeceptJS do not expose them to tests by design, keeping test to be action focused. +If you need to get access to web elements, it is recommended to implement operations for web elements in a custom helper. + +To get access for elements, connect to a corresponding helper and use `_locate` function to match web elements by CSS or XPath, like you usually do: + +### Acessing Elements in WebDriver + +```js +// inside a custom helper +async clickOnEveryElement(locator) { + const { WebDriver } = this.helpers; + const els = await WebDriver._locate(locator); + + for (let el of els) { + await el.click(); + } +} +``` +In this case an an instance of webdriverio element is used. +To get a [complete API of an element](https://webdriver.io/docs/api/) refer to webdriverio docs. + +### Accessing Elements in Playwright & Puppeteer + +Similar method can be implemented for Playwright & Puppeteer: + +```js +// inside a custom helper +async clickOnEveryElement(locator) { + const { Playwright } = this.helpers; + const els = await Playwright._locate(locator); + + for (let el of els) { + await el.click(); + } +} +``` + +In this case `el` will be an instance of [ElementHandle](https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#class-elementhandle) which is similar for Playwright & [Puppeteer](https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-elementhandle). + +> ℹ There are more `_locate*` methods in each helper. Take a look on documentation of a helper you use to see which exact method it exposes. + ## Configuration Helpers should be enabled inside `codecept.json` or `codecept.conf.js` files. Command `generate helper` @@ -175,13 +220,13 @@ does that for you, however you can enable them manually by placing helper to `he You can also pass additional config options to your helper from a config - **(please note, this example contains comments, while JSON format doesn't support them)**: ```js -"helpers": { +helpers: { // here goes standard helpers: // WebDriver, Protractor, Nightmare, etc... // and their configuration - "MyHelper": { - "require": "./my_helper.js", // path to module - "defaultHost": "http://mysite.com" // custom config param + MyHelper: { + require: "./my_helper.js", // path to module + defaultHost: "http://mysite.com" // custom config param } } diff --git a/docs/helpers/Appium.md b/docs/helpers/Appium.md index 965a9cec6..82e78c615 100644 --- a/docs/helpers/Appium.md +++ b/docs/helpers/Appium.md @@ -1107,6 +1107,30 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal'); - `sec` **[number][8]** (optional, `1` by default) time in seconds to wait (optional, default `1`) - `context` **([string][4] \| [object][6])?** (optional) element located by CSS|XPath|strict locator. (optional, default `null`) +### \_isShadowLocator + +Check if locator is type of "Shadow" + +#### Parameters + +- `locator` **[object][6]** + +### \_locateShadow + +Locate Element within the Shadow Dom + +#### Parameters + +- `locator` **[object][6]** + +### \_smartWait + +Smart Wait to locate an element + +#### Parameters + +- `locator` **[object][6]** + ### \_locate Get elements by different locator types, including strict locator. @@ -1477,6 +1501,8 @@ I.moveCursorTo('#submit', 5,5); #### Parameters - `locator` **([string][4] \| [object][6])** located by CSS|XPath|strict locator. +- `xOffset` +- `yOffset` - `offsetX` **[number][8]** (optional, `0` by default) X-axis offset. (optional, default `0`) - `offsetY` **[number][8]** (optional, `0` by default) Y-axis offset. (optional, default `0`) diff --git a/docs/helpers/Nightmare.md b/docs/helpers/Nightmare.md index 7829cda42..dcc74f483 100644 --- a/docs/helpers/Nightmare.md +++ b/docs/helpers/Nightmare.md @@ -876,15 +876,23 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']); ### setCookie -Sets a cookie. +Sets cookie(s). + +Can be a single cookie object or an array of cookies: ```js I.setCookie({name: 'auth', value: true}); + +// as array +I.setCookie([ + {name: 'auth', value: true}, + {name: 'agree', value: true} +]); ``` #### Parameters -- `cookie` **[object][4]** a cookie object.Wrapper for `.cookies.set(cookie)`. +- `cookie` **([object][4] | [array][11])** a cookie object or array of cookie objects.Wrapper for `.cookies.set(cookie)`. [See more][14] ### triggerMouseEvent diff --git a/docs/helpers/Playwright.md b/docs/helpers/Playwright.md index cdf451da0..500337d54 100644 --- a/docs/helpers/Playwright.md +++ b/docs/helpers/Playwright.md @@ -32,6 +32,7 @@ This helper should be configured in codecept.json or codecept.conf.js - `show`: - show browser window. - `restart`: - restart browser between tests. - `disableScreenshots`: - don't save screenshot on failure. +- `emulate`: launch browser in device emulation mode. - `fullPageScreenshots` - make full page screenshots on failure. - `uniqueScreenshotNames`: - option to prevent screenshot override if you have scenarios with the same name in different suites. - `keepBrowserState`: - keep browser state between tests when `restart` is set to false. @@ -126,6 +127,21 @@ This helper should be configured in codecept.json or codecept.conf.js } ``` +#### Example #6: Lunach tests emulating iPhone 6 + +```js +const { devices } = require('playwright'); + +{ + helpers: { + Playwright: { + url: "http://localhost", + emulate: devices['iPhone 6'], + } + } +} +``` + Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored. ## Access From Helpers @@ -376,16 +392,12 @@ I.click({css: 'nav a.login'}); ### clickLink -Performs a click on a link and waits for navigation before moving on. - -```js -I.clickLink('Logout', '#nav'); -``` +Clicks link and waits for navigation (deprecated) #### Parameters -- `locator` **([string][7] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator -- `context` **([string][7]? | [object][5])** (optional, `null` by default) element to search in CSS|XPath|Strict locator +- `locator` +- `context` ### closeCurrentTab @@ -575,68 +587,33 @@ I.dragSlider('#slider', -70); - `locator` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator. - `offsetX` **[number][8]** position to drag. -### executeAsyncScript - -Executes async script on page. -Provided function should execute a passed callback (as first argument) to signal it is finished. +### executeScript -Example: In Vue.js to make components completely rendered we are waiting for [nextTick][9]. +Executes a script on the page: ```js -I.executeAsyncScript(function(done) { - Vue.nextTick(done); // waiting for next tick -}); +I.executeScript(() => window.alert('Hello world')); ``` -By passing value to `done()` function you can return values. -Additional arguments can be passed as well, while `done` function is always last parameter in arguments list. +Additional parameters of the function can be passed as an object argument: ```js -let val = await I.executeAsyncScript(function(url, done) { - // in browser context - $.ajax(url, { success: (data) => done(data); } -}, 'http://ajax.callback.url/'); +I.executeScript(({x, y}) => x + y, {x, y}); ``` -#### Parameters - -- `fn` **([string][7] | [function][10])** function to be executed in browser context. -- `args` **...any** to be passed to function. - -Returns **[Promise][11]<any>** Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise. - -### executeScript - -Executes sync script on a page. -Pass arguments to function as additional parameters. -Will return execution result to a test. -In this case you should use async function and await to receive results. - -Example with jQuery DatePicker: +You can pass only one parameter into a function +but you can pass in array or object. ```js -// change date of jQuery DatePicker -I.executeScript(function() { - // now we are inside browser context - $('date').datetimepicker('setDate', new Date()); -}); +I.executeScript(([x, y]) => x + y, [x, y]); ``` -Can return values. Don't forget to use `await` to get them. - -```js -let date = await I.executeScript(function(el) { - // only basic types can be returned - return $(el).datetimepicker('getDate').toString(); -}, '#date'); // passing jquery selector -``` +If a function returns a Promise it will wait for its resolution. #### Parameters -- `fn` **([string][7] | [function][10])** function to be executed in browser context. -- `args` **...any** to be passed to function. - -Returns **[Promise][11]<any>** If a function returns a Promise It will wait for it resolution. +- `fn` +- `arg` ### fillField @@ -659,6 +636,20 @@ I.fillField({css: 'form#login input[name=username]'}, 'John'); - `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator. - `value` **[string][7]** text value to fill. +### forceClick + +Force clicks an element without waiting for it to become visible and not animating. + +```js +I.forceClick('#hiddenButton'); +I.forceClick('Click me', '#hidden'); +``` + +#### Parameters + +- `locator` +- `context` + ### grabAttributeFrom Retrieves an attribute from an element located by CSS or XPath and returns it to test. @@ -674,7 +665,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title'); - `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator. - `attr` **[string][7]** attribute name. -Returns **[Promise][11]<[string][7]>** attribute value +Returns **[Promise][9]<[string][7]>** attribute value ### grabBrowserLogs @@ -685,7 +676,7 @@ let logs = await I.grabBrowserLogs(); console.log(JSON.stringify(logs)) ``` -Returns **[Promise][11]<[Array][12]<any>>** +Returns **[Promise][9]<[Array][10]<any>>** ### grabCookie @@ -702,7 +693,7 @@ assert(cookie.value, '123456'); - `name` **[string][7]?** cookie name. -Returns **[Promise][11]<[string][7]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain. +Returns **[Promise][9]<[string][7]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain. ### grabCssPropertyFrom @@ -718,7 +709,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight'); - `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator. - `cssProperty` **[string][7]** CSS property name. -Returns **[Promise][11]<[string][7]>** CSS value +Returns **[Promise][9]<[string][7]>** CSS value ### grabCurrentUrl @@ -730,7 +721,7 @@ let url = await I.grabCurrentUrl(); console.log(`Current URL is [${url}]`); ``` -Returns **[Promise][11]<[string][7]>** current URL +Returns **[Promise][9]<[string][7]>** current URL ### grabDataFromPerformanceTiming @@ -798,7 +789,7 @@ let postHTML = await I.grabHTMLFrom('#post'); - `locator` - `element` **([string][7] | [object][5])** located by CSS|XPath|strict locator. -Returns **[Promise][11]<[string][7]>** HTML code for an element +Returns **[Promise][9]<[string][7]>** HTML code for an element ### grabNumberOfOpenTabs @@ -808,7 +799,7 @@ Grab number of open tabs. let tabs = await I.grabNumberOfOpenTabs(); ``` -Returns **[Promise][11]<[number][8]>** number of open tabs +Returns **[Promise][9]<[number][8]>** number of open tabs ### grabNumberOfVisibleElements @@ -822,7 +813,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p'); - `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator. -Returns **[Promise][11]<[number][8]>** number of visible elements +Returns **[Promise][9]<[number][8]>** number of visible elements ### grabPageScrollPosition @@ -833,7 +824,7 @@ Resumes test execution, so **should be used inside an async function with `await let { x, y } = await I.grabPageScrollPosition(); ``` -Returns **[Promise][11]<[Object][5]<[string][7], any>>** scroll position +Returns **[Promise][9]<[Object][5]<[string][7], any>>** scroll position ### grabPopupText @@ -843,7 +834,7 @@ Grab the text within the popup. If no popup is visible then it will return null await I.grabPopupText(); ``` -Returns **[Promise][11]<([string][7] | null)>** +Returns **[Promise][9]<([string][7] | null)>** ### grabSource @@ -854,7 +845,7 @@ Resumes test execution, so should be used inside an async function. let pageSource = await I.grabSource(); ``` -Returns **[Promise][11]<[string][7]>** source code +Returns **[Promise][9]<[string][7]>** source code ### grabTextFrom @@ -871,7 +862,7 @@ If multiple elements found returns an array of texts. - `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator. -Returns **[Promise][11]<([string][7] | [Array][12]<[string][7]>)>** attribute value +Returns **[Promise][9]<([string][7] | [Array][10]<[string][7]>)>** attribute value ### grabTitle @@ -882,7 +873,7 @@ Resumes test execution, so **should be used inside async with `await`** operator let title = await I.grabTitle(); ``` -Returns **[Promise][11]<[string][7]>** title +Returns **[Promise][9]<[string][7]>** title ### grabValueFrom @@ -897,7 +888,7 @@ let email = await I.grabValueFrom('input[name=email]'); - `locator` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator. -Returns **[Promise][11]<[string][7]>** attribute value +Returns **[Promise][9]<[string][7]>** attribute value ### haveRequestHeaders @@ -937,11 +928,22 @@ Open new tab and switch to it I.openNewTab(); ``` +You can pass in [page options][11] to emulate device on this page + +```js +// enable mobile +I.openNewTab({ isMobile: true }); +``` + +#### Parameters + +- `options` + ### pressKey Presses a key in the browser (on a focused element). -_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][13]. +_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][12]. ```js I.pressKey('Backspace'); @@ -1000,13 +1002,13 @@ Some of the supported key names are: #### Parameters -- `key` **([string][7] | [Array][12]<[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313][14]). +- `key` **([string][7] | [Array][10]<[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313][13]). ### pressKeyDown Presses a key in the browser and leaves it in a down state. -To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]). +To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][14]). ```js I.pressKeyDown('Control'); @@ -1022,7 +1024,7 @@ I.pressKeyUp('Control'); Releases a key in the browser which was previously set to a down state. -To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]). +To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][14]). ```js I.pressKeyDown('Control'); @@ -1090,7 +1092,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro #### Parameters - `fileName` **[string][7]** file name to save. -- `fullPage` **[boolean][16]** (optional, `false` by default) flag to enable fullscreen screenshot mode. +- `fullPage` **[boolean][15]** (optional, `false` by default) flag to enable fullscreen screenshot mode. ### scrollPageToBottom @@ -1376,19 +1378,27 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']); #### Parameters - `select` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator. -- `option` **([string][7] | [Array][12]<any>)** visible text or value of option. +- `option` **([string][7] | [Array][10]<any>)** visible text or value of option. ### setCookie -Sets a cookie. +Sets cookie(s). + +Can be a single cookie object or an array of cookies: ```js I.setCookie({name: 'auth', value: true}); + +// as array +I.setCookie([ + {name: 'auth', value: true}, + {name: 'agree', value: true} +]); ``` #### Parameters -- `cookie` **[object][5]** a cookie object. +- `cookie` **([object][5] | [array][10])** a cookie object or array of cookie objects. ### switchTo @@ -1531,8 +1541,8 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and #### Parameters -- `fn` **([string][7] | [function][10])** to be executed in browser context. -- `argsOrSec` **([Array][12]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds. +- `fn` **([string][7] | [function][16])** to be executed in browser context. +- `argsOrSec` **([Array][10]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds. - `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait ### waitForInvisible @@ -1570,7 +1580,7 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me #### Parameters -- `urlOrPredicate` **([string][7] | [function][10])** +- `urlOrPredicate` **([string][7] | [function][16])** - `sec` **[number][8]?** seconds to wait ### waitForResponse @@ -1584,7 +1594,7 @@ I.waitForResponse(request => request.url() === 'http://example.com' && request.m #### Parameters -- `urlOrPredicate` **([string][7] | [function][10])** +- `urlOrPredicate` **([string][7] | [function][16])** - `sec` **[number][8]?** number of seconds to wait ### waitForText @@ -1684,7 +1694,7 @@ I.waitUntil(() => window.requests == 0, 5); #### Parameters -- `fn` **([function][10] | [string][7])** function which is executed in browser context. +- `fn` **([function][16] | [string][7])** function which is executed in browser context. - `sec` **[number][8]** (optional, `1` by default) time in seconds to wait - `timeoutMsg` **[string][7]** message to show in case of timeout fail. - `interval` **[number][8]?** @@ -1719,20 +1729,20 @@ I.waitUrlEquals('http://127.0.0.1:8000/info'); [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[9]: https://vuejs.org/v2/api/#Vue-nextTick +[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[11]: https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#browsernewpageoptions -[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[12]: #fillfield -[13]: #fillfield +[13]: https://github.com/GoogleChrome/Playwright/issues/1313 -[14]: https://github.com/GoogleChrome/Playwright/issues/1313 +[14]: #click -[15]: #click +[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function [17]: https://codecept.io/react diff --git a/docs/helpers/Protractor.md b/docs/helpers/Protractor.md index fe0bb3544..3e0ec6440 100644 --- a/docs/helpers/Protractor.md +++ b/docs/helpers/Protractor.md @@ -1207,15 +1207,23 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']); ### setCookie -Sets a cookie. +Sets cookie(s). + +Can be a single cookie object or an array of cookies: ```js I.setCookie({name: 'auth', value: true}); + +// as array +I.setCookie([ + {name: 'auth', value: true}, + {name: 'agree', value: true} +]); ``` #### Parameters -- `cookie` **[object][10]** a cookie object. +- `cookie` **([object][10] | [array][14])** a cookie object or array of cookie objects. ### switchTo diff --git a/docs/helpers/Puppeteer.md b/docs/helpers/Puppeteer.md index c0d60459c..9a3092abc 100644 --- a/docs/helpers/Puppeteer.md +++ b/docs/helpers/Puppeteer.md @@ -287,7 +287,7 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg'); #### Parameters - `locator` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator. -- `pathToFile` **[string][8]** local file path relative to codecept.json config file. +- `pathToFile` **[string][8]** local file path relative to codecept.json config file.> ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][9], downgrade to 2.0.0 if you face it. ### cancelPopup @@ -601,7 +601,7 @@ I.dragSlider('#slider', -70); #### Parameters - `locator` **([string][8] | [object][6])** located by label|name|CSS|XPath|strict locator. -- `offsetX` **[number][9]** position to drag. +- `offsetX` **[number][10]** position to drag. @@ -613,7 +613,7 @@ This action supports [React locators](https://codecept.io/react#locators) Executes async script on page. Provided function should execute a passed callback (as first argument) to signal it is finished. -Example: In Vue.js to make components completely rendered we are waiting for [nextTick][10]. +Example: In Vue.js to make components completely rendered we are waiting for [nextTick][11]. ```js I.executeAsyncScript(function(done) { @@ -633,10 +633,10 @@ let val = await I.executeAsyncScript(function(url, done) { #### Parameters -- `fn` **([string][8] | [function][11])** function to be executed in browser context. +- `fn` **([string][8] | [function][12])** function to be executed in browser context. - `args` **...any** to be passed to function. -Returns **[Promise][12]<any>** Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise. +Returns **[Promise][13]<any>** Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise. ### executeScript @@ -666,10 +666,10 @@ let date = await I.executeScript(function(el) { #### Parameters -- `fn` **([string][8] | [function][11])** function to be executed in browser context. +- `fn` **([string][8] | [function][12])** function to be executed in browser context. - `args` **...any** to be passed to function. -Returns **[Promise][12]<any>** If a function returns a Promise It will wait for it resolution. +Returns **[Promise][13]<any>** If a function returns a Promise It will wait for it resolution. ### fillField @@ -711,7 +711,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title'); - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. - `attr` **[string][8]** attribute name. -Returns **[Promise][12]<[string][8]>** attribute value +Returns **[Promise][13]<[string][8]>** attribute value @@ -727,7 +727,7 @@ let logs = await I.grabBrowserLogs(); console.log(JSON.stringify(logs)) ``` -Returns **[Promise][12]<[Array][13]<any>>** +Returns **[Promise][13]<[Array][14]<any>>** ### grabCookie @@ -744,7 +744,7 @@ assert(cookie.value, '123456'); - `name` **[string][8]?** cookie name. -Returns **[Promise][12]<[string][8]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain. +Returns **[Promise][13]<[string][8]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain. ### grabCssPropertyFrom @@ -760,7 +760,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight'); - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. - `cssProperty` **[string][8]** CSS property name. -Returns **[Promise][12]<[string][8]>** CSS value +Returns **[Promise][13]<[string][8]>** CSS value @@ -777,7 +777,7 @@ let url = await I.grabCurrentUrl(); console.log(`Current URL is [${url}]`); ``` -Returns **[Promise][12]<[string][8]>** current URL +Returns **[Promise][13]<[string][8]>** current URL ### grabDataFromPerformanceTiming @@ -845,7 +845,7 @@ let postHTML = await I.grabHTMLFrom('#post'); - `locator` - `element` **([string][8] | [object][6])** located by CSS|XPath|strict locator. -Returns **[Promise][12]<[string][8]>** HTML code for an element +Returns **[Promise][13]<[string][8]>** HTML code for an element ### grabNumberOfOpenTabs @@ -855,7 +855,7 @@ Grab number of open tabs. let tabs = await I.grabNumberOfOpenTabs(); ``` -Returns **[Promise][12]<[number][9]>** number of open tabs +Returns **[Promise][13]<[number][10]>** number of open tabs ### grabNumberOfVisibleElements @@ -869,7 +869,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p'); - `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator. -Returns **[Promise][12]<[number][9]>** number of visible elements +Returns **[Promise][13]<[number][10]>** number of visible elements @@ -885,7 +885,7 @@ Resumes test execution, so **should be used inside an async function with `await let { x, y } = await I.grabPageScrollPosition(); ``` -Returns **[Promise][12]<[Object][6]<[string][8], any>>** scroll position +Returns **[Promise][13]<[Object][6]<[string][8], any>>** scroll position ### grabPopupText @@ -895,7 +895,7 @@ Grab the text within the popup. If no popup is visible then it will return null await I.grabPopupText(); ``` -Returns **[Promise][12]<([string][8] | null)>** +Returns **[Promise][13]<([string][8] | null)>** ### grabSource @@ -906,7 +906,7 @@ Resumes test execution, so should be used inside an async function. let pageSource = await I.grabSource(); ``` -Returns **[Promise][12]<[string][8]>** source code +Returns **[Promise][13]<[string][8]>** source code ### grabTextFrom @@ -923,7 +923,7 @@ If multiple elements found returns an array of texts. - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -Returns **[Promise][12]<([string][8] | [Array][13]<[string][8]>)>** attribute value +Returns **[Promise][13]<([string][8] | [Array][14]<[string][8]>)>** attribute value @@ -939,7 +939,7 @@ Resumes test execution, so **should be used inside async with `await`** operator let title = await I.grabTitle(); ``` -Returns **[Promise][12]<[string][8]>** title +Returns **[Promise][13]<[string][8]>** title ### grabValueFrom @@ -954,12 +954,12 @@ let email = await I.grabValueFrom('input[name=email]'); - `locator` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator. -Returns **[Promise][12]<[string][8]>** attribute value +Returns **[Promise][13]<[string][8]>** attribute value ### handleDownloads Sets a directory to where save files. Allows to test file downloads. -Should be used with [FileSystem helper][14] to check that file were downloaded correctly. +Should be used with [FileSystem helper][15] to check that file were downloaded correctly. By default files are saved to `output/downloads`. This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept. @@ -1002,8 +1002,8 @@ I.moveCursorTo('#submit', 5,5); #### Parameters - `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator. -- `offsetX` **[number][9]** (optional, `0` by default) X-axis offset. -- `offsetY` **[number][9]** (optional, `0` by default) Y-axis offset. +- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset. +- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset. This action supports [React locators](https://codecept.io/react#locators) @@ -1021,7 +1021,7 @@ I.openNewTab(); Presses a key in the browser (on a focused element). -_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][15]. +_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][16]. ```js I.pressKey('Backspace'); @@ -1080,13 +1080,13 @@ Some of the supported key names are: #### Parameters -- `key` **([string][8] | [Array][13]<[string][8]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][16]). +- `key` **([string][8] | [Array][14]<[string][8]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][17]). ### pressKeyDown Presses a key in the browser and leaves it in a down state. -To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][17]). +To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][18]). ```js I.pressKeyDown('Control'); @@ -1102,7 +1102,7 @@ I.pressKeyUp('Control'); Releases a key in the browser which was previously set to a down state. -To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][17]). +To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][18]). ```js I.pressKeyDown('Control'); @@ -1129,8 +1129,8 @@ First parameter can be set to `maximize`. #### Parameters -- `width` **[number][9]** width in pixels or `maximize`. -- `height` **[number][9]** height in pixels.Unlike other drivers Puppeteer changes the size of a viewport, not the window! +- `width` **[number][10]** width in pixels or `maximize`. +- `height` **[number][10]** height in pixels.Unlike other drivers Puppeteer changes the size of a viewport, not the window! Puppeteer does not control the window of a browser so it can't adjust its real size. It also can't maximize a window. @@ -1170,7 +1170,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro #### Parameters - `fileName` **[string][8]** file name to save. -- `fullPage` **[boolean][18]** (optional, `false` by default) flag to enable fullscreen screenshot mode. +- `fullPage` **[boolean][19]** (optional, `false` by default) flag to enable fullscreen screenshot mode. ### scrollPageToBottom @@ -1201,8 +1201,8 @@ I.scrollTo('#submit', 5, 5); #### Parameters - `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator. -- `offsetX` **[number][9]** (optional, `0` by default) X-axis offset. -- `offsetY` **[number][9]** (optional, `0` by default) Y-axis offset. +- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset. +- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset. ### see @@ -1410,7 +1410,7 @@ I.seeNumberOfElements('#submitBtn', 1); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `num` **[number][9]** number of elements. +- `num` **[number][10]** number of elements. This action supports [React locators](https://codecept.io/react#locators) @@ -1428,7 +1428,7 @@ I.seeNumberOfVisibleElements('.buttons', 3); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `num` **[number][9]** number of elements. +- `num` **[number][10]** number of elements. This action supports [React locators](https://codecept.io/react#locators) @@ -1483,19 +1483,27 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']); #### Parameters - `select` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator. -- `option` **([string][8] | [Array][13]<any>)** visible text or value of option. +- `option` **([string][8] | [Array][14]<any>)** visible text or value of option. ### setCookie -Sets a cookie. +Sets cookie(s). + +Can be a single cookie object or an array of cookies: ```js I.setCookie({name: 'auth', value: true}); + +// as array +I.setCookie([ + {name: 'auth', value: true}, + {name: 'agree', value: true} +]); ``` #### Parameters -- `cookie` **[object][6]** a cookie object. +- `cookie` **([object][6] | [array][14])** a cookie object or array of cookie objects. ### switchTo @@ -1521,7 +1529,7 @@ I.switchToNextTab(2); #### Parameters -- `num` **[number][9]** +- `num` **[number][10]** ### switchToPreviousTab @@ -1534,7 +1542,7 @@ I.switchToPreviousTab(2); #### Parameters -- `num` **[number][9]** +- `num` **[number][10]** ### uncheckOption @@ -1564,7 +1572,7 @@ I.wait(2); // wait 2 secs #### Parameters -- `sec` **[number][9]** number of second to wait. +- `sec` **[number][10]** number of second to wait. ### waitForClickable @@ -1580,7 +1588,7 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. - `waitTimeout` -- `sec` **[number][9]?** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait ### waitForDetached @@ -1594,7 +1602,7 @@ I.waitForDetached('#popup'); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait ### waitForElement @@ -1609,7 +1617,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]?** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait @@ -1624,7 +1632,7 @@ Element can be located by CSS or XPath. #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]** (optional) time in seconds to wait, 1 by default. +- `sec` **[number][10]** (optional) time in seconds to wait, 1 by default. ### waitForFunction @@ -1643,9 +1651,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and #### Parameters -- `fn` **([string][8] | [function][11])** to be executed in browser context. -- `argsOrSec` **([Array][13]<any> | [number][9])?** (optional, `1` by default) arguments for function or seconds. -- `sec` **[number][9]?** (optional, `1` by default) time in seconds to wait +- `fn` **([string][8] | [function][12])** to be executed in browser context. +- `argsOrSec` **([Array][14]<any> | [number][10])?** (optional, `1` by default) arguments for function or seconds. +- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait ### waitForInvisible @@ -1659,7 +1667,7 @@ I.waitForInvisible('#popup'); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait ### waitForNavigation @@ -1682,8 +1690,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me #### Parameters -- `urlOrPredicate` **([string][8] | [function][11])** -- `sec` **[number][9]?** seconds to wait +- `urlOrPredicate` **([string][8] | [function][12])** +- `sec` **[number][10]?** seconds to wait ### waitForResponse @@ -1696,8 +1704,8 @@ I.waitForResponse(request => request.url() === 'http://example.com' && request.m #### Parameters -- `urlOrPredicate` **([string][8] | [function][11])** -- `sec` **[number][9]?** number of seconds to wait +- `urlOrPredicate` **([string][8] | [function][12])** +- `sec` **[number][10]?** number of seconds to wait ### waitForText @@ -1713,7 +1721,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal'); #### Parameters - `text` **[string][8]** to wait for. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait - `context` **([string][8] | [object][6])?** (optional) element located by CSS|XPath|strict locator. ### waitForValue @@ -1728,7 +1736,7 @@ I.waitForValue('//input', "GoodValue"); - `field` **([string][8] | [object][6])** input field. - `value` **[string][8]** expected value. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait ### waitForVisible @@ -1742,7 +1750,7 @@ I.waitForVisible('#popup'); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][19]. +- `sec` **[number][10]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][20]. ### waitInUrl @@ -1755,7 +1763,7 @@ I.waitInUrl('/info', 2); #### Parameters - `urlPart` **[string][8]** value to check. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait ### waitNumberOfVisibleElements @@ -1768,8 +1776,8 @@ I.waitNumberOfVisibleElements('a', 3); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `num` **[number][9]** number of elements. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `num` **[number][10]** number of elements. +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait @@ -1788,7 +1796,7 @@ I.waitToHide('#popup'); #### Parameters - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait ### waitUntil @@ -1801,10 +1809,10 @@ I.waitUntil(() => window.requests == 0, 5); #### Parameters -- `fn` **([function][11] | [string][8])** function which is executed in browser context. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `fn` **([function][12] | [string][8])** function which is executed in browser context. +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait - `timeoutMsg` **[string][8]** message to show in case of timeout fail. -- `interval` **[number][9]?** +- `interval` **[number][10]?** ### waitUrlEquals @@ -1818,7 +1826,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info'); #### Parameters - `urlPart` **[string][8]** value to check. -- `sec` **[number][9]** (optional, `1` by default) time in seconds to wait +- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait [1]: https://github.com/GoogleChrome/puppeteer @@ -1836,24 +1844,26 @@ I.waitUrlEquals('http://127.0.0.1:8000/info'); [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[9]: https://github.com/puppeteer/puppeteer/issues/5420 + +[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[10]: https://vuejs.org/v2/api/#Vue-nextTick +[11]: https://vuejs.org/v2/api/#Vue-nextTick -[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[14]: https://codecept.io/helpers/FileSystem +[15]: https://codecept.io/helpers/FileSystem -[15]: #fillfield +[16]: #fillfield -[16]: https://github.com/GoogleChrome/puppeteer/issues/1313 +[17]: https://github.com/GoogleChrome/puppeteer/issues/1313 -[17]: #click +[18]: #click -[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[19]: https://codecept.io/react +[20]: https://codecept.io/react diff --git a/docs/helpers/TestCafe.md b/docs/helpers/TestCafe.md index 89e788675..686fcddbd 100644 --- a/docs/helpers/TestCafe.md +++ b/docs/helpers/TestCafe.md @@ -852,15 +852,23 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']); ### setCookie -Sets a cookie. +Sets cookie(s). + +Can be a single cookie object or an array of cookies: ```js I.setCookie({name: 'auth', value: true}); + +// as array +I.setCookie([ + {name: 'auth', value: true}, + {name: 'agree', value: true} +]); ``` #### Parameters -- `cookie` **[object][5]** a cookie object. +- `cookie` **([object][5] | [array][9])** a cookie object or array of cookie objects. ### switchTo diff --git a/docs/helpers/WebDriver.md b/docs/helpers/WebDriver.md index 23a36e7ec..60f0f3c93 100644 --- a/docs/helpers/WebDriver.md +++ b/docs/helpers/WebDriver.md @@ -352,6 +352,14 @@ const browser = WebDriver.browser - `config` +### _isShadowLocator + +Check if locator is type of "Shadow" + +#### Parameters + +- `locator` **[object][18]** + ### _locate Get elements by different locator types, including strict locator. @@ -363,7 +371,7 @@ this.helpers['WebDriver']._locate({name: 'password'}).then //... #### Parameters -- `locator` **([string][18] | [object][19])** element located by CSS|XPath|strict locator. +- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator. - `smartWait` ### _locateCheckable @@ -376,7 +384,7 @@ this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions'). #### Parameters -- `locator` **([string][18] | [object][19])** element located by CSS|XPath|strict locator. +- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator. ### _locateClickable @@ -388,7 +396,7 @@ this.helpers['WebDriver']._locateClickable('Next page').then // ... #### Parameters -- `locator` **([string][18] | [object][19])** element located by CSS|XPath|strict locator. +- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator. ### _locateFields @@ -400,7 +408,23 @@ this.helpers['WebDriver']._locateFields('Your email').then // ... #### Parameters -- `locator` **([string][18] | [object][19])** element located by CSS|XPath|strict locator. +- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator. + +### _locateShadow + +Locate Element within the Shadow Dom + +#### Parameters + +- `locator` **[object][18]** + +### _smartWait + +Smart Wait to locate an element + +#### Parameters + +- `locator` **[object][18]** ### acceptPopup @@ -421,7 +445,7 @@ I.amOnPage('/login'); // opens a login page #### Parameters -- `url` **[string][18]** url path or global url. +- `url` **[string][19]** url path or global url. ### appendField @@ -434,8 +458,8 @@ I.appendField('#myTextField', 'appended'); #### Parameters -- `field` **([string][18] | [object][19])** located by label|name|CSS|XPath|strict locator -- `value` **[string][18]** text value to append. +- `field` **([string][19] | [object][18])** located by label|name|CSS|XPath|strict locator +- `value` **[string][19]** text value to append. @@ -455,8 +479,8 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg'); #### Parameters -- `locator` **([string][18] | [object][19])** field located by label|name|CSS|XPath|strict locator. -- `pathToFile` **[string][18]** local file path relative to codecept.json config file. +- `locator` **([string][19] | [object][18])** field located by label|name|CSS|XPath|strict locator. +- `pathToFile` **[string][19]** local file path relative to codecept.json config file. Appium: not tested ### cancelPopup @@ -478,8 +502,8 @@ I.checkOption('agree', '//form'); #### Parameters -- `field` **([string][18] | [object][19])** checkbox located by label | name | CSS | XPath | strict locator. -- `context` **([string][18]? | [object][19])** (optional, `null` by default) element located by CSS | XPath | strict locator. +- `field` **([string][19] | [object][18])** checkbox located by label | name | CSS | XPath | strict locator. +- `context` **([string][19]? | [object][18])** (optional, `null` by default) element located by CSS | XPath | strict locator. Appium: not tested ### clearCookie @@ -494,7 +518,7 @@ I.clearCookie('test'); #### Parameters -- `cookie` **[string][18]?** (optional, `null` by default) cookie name +- `cookie` **[string][19]?** (optional, `null` by default) cookie name ### clearField @@ -509,7 +533,7 @@ I.clearField('#email'); #### Parameters - `field` -- `editable` **([string][18] | [object][19])** field located by label|name|CSS|XPath|strict locator. +- `editable` **([string][19] | [object][18])** field located by label|name|CSS|XPath|strict locator. ### click @@ -537,8 +561,8 @@ I.click({css: 'nav a.login'}); #### Parameters -- `locator` **([string][18] | [object][19])** clickable link or button located by text, or any element located by CSS|XPath|strict locator. -- `context` **([string][18]? | [object][19])** (optional, `null` by default) element to search in CSS|XPath|Strict locator. +- `locator` **([string][19] | [object][18])** clickable link or button located by text, or any element located by CSS|XPath|strict locator. +- `context` **([string][19]? | [object][18])** (optional, `null` by default) element to search in CSS|XPath|Strict locator. This action supports [React locators](https://codecept.io/react#locators) @@ -587,8 +611,8 @@ I.dontSee('Login', '.nav'); // no login inside .nav element #### Parameters -- `text` **[string][18]** which is not present. -- `context` **([string][18] | [object][19])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search. +- `text` **[string][19]** which is not present. +- `context` **([string][19] | [object][18])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search. This action supports [React locators](https://codecept.io/react#locators) @@ -606,7 +630,7 @@ I.dontSeeCheckboxIsChecked('agree'); // located by name #### Parameters -- `field` **([string][18] | [object][19])** located by label|name|CSS|XPath|strict locator.Appium: not tested +- `field` **([string][19] | [object][18])** located by label|name|CSS|XPath|strict locator.Appium: not tested ### dontSeeCookie @@ -618,7 +642,7 @@ I.dontSeeCookie('auth'); // no auth cookie #### Parameters -- `name` **[string][18]** cookie name. +- `name` **[string][19]** cookie name. ### dontSeeCurrentUrlEquals @@ -632,7 +656,7 @@ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also #### Parameters -- `url` **[string][18]** value to check. +- `url` **[string][19]** value to check. ### dontSeeElement @@ -644,7 +668,7 @@ I.dontSeeElement('.modal'); // modal is not shown #### Parameters -- `locator` **([string][18] | [object][19])** located by CSS|XPath|Strict locator. +- `locator` **([string][19] | [object][18])** located by CSS|XPath|Strict locator. @@ -661,7 +685,7 @@ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or #### Parameters -- `locator` **([string][18] | [object][19])** located by CSS|XPath|Strict locator. +- `locator` **([string][19] | [object][18])** located by CSS|XPath|Strict locator. ### dontSeeInCurrentUrl @@ -669,7 +693,7 @@ Checks that current url does not contain a provided fragment. #### Parameters -- `url` **[string][18]** value to check. +- `url` **[string][19]** value to check. ### dontSeeInField @@ -683,8 +707,8 @@ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS #### Parameters -- `field` **([string][18] | [object][19])** located by label|name|CSS|XPath|strict locator. -- `value` **[string][18]** value to check. +- `field` **([string][19] | [object][18])** located by label|name|CSS|XPath|strict locator. +- `value` **[string][19]** value to check. ### dontSeeInSource @@ -697,7 +721,7 @@ I.dontSeeInSource('