codeceptjs 4.2.0-beta.4 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1534,6 +1534,29 @@ class Appium extends Webdriver {
1534
1534
  return this.browser.closeApp()
1535
1535
  }
1536
1536
 
1537
+ /**
1538
+ * {{> clearClipboard }}
1539
+ *
1540
+ * Appium: support both Android and iOS
1541
+ */
1542
+ async clearClipboard() {
1543
+ if (typeof this.browser.setClipboard !== 'function') return super.clearClipboard()
1544
+ return this.browser.setClipboard('', 'plaintext')
1545
+ }
1546
+
1547
+ /**
1548
+ * {{> grabFromClipboard }}
1549
+ *
1550
+ * Appium: support both Android and iOS
1551
+ */
1552
+ async grabFromClipboard() {
1553
+ if (typeof this.browser.getClipboard !== 'function') return super.grabFromClipboard()
1554
+ const encoded = await this.browser.getClipboard('plaintext')
1555
+ const clipboard = Buffer.from(encoded || '', 'base64').toString('utf8')
1556
+ this.debugSection('Clipboard', clipboard)
1557
+ return clipboard
1558
+ }
1559
+
1537
1560
  /**
1538
1561
  * {{> appendField }}
1539
1562
  *
@@ -18,6 +18,7 @@ import { isColorProperty, convertColorToRGBA } from '../colorUtils.js'
18
18
  import WebElement from '../element/WebElement.js'
19
19
  import CDPElementHandle from './extras/CDPElementHandle.js'
20
20
  import { checkFocusBeforeType, checkFocusBeforePressKey } from './extras/focusCheck.js'
21
+ import { CLIPBOARD_READ_TIMEOUT_MS, readClipboardScript, writeClipboardScript, clipboardExpression } from './extras/clipboard.js'
21
22
  import { dontSeeTraffic, seeTraffic, grabRecordedNetworkTraffics, flushNetworkTraffics } from './network/actions.js'
22
23
  import { assembleApng, isPng } from './extras/apngAssembler.js'
23
24
 
@@ -1940,6 +1941,89 @@ class CDPBrowser extends Helper {
1940
1941
  }
1941
1942
  }
1942
1943
 
1944
+ /**
1945
+ * Checks that the system clipboard contains the given text.
1946
+ *
1947
+ * ```js
1948
+ * I.click('Copy to clipboard');
1949
+ * I.seeInClipboard('https://codecept.io');
1950
+ * ```
1951
+ *
1952
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
1953
+ *
1954
+ * @param {string} text value to check.
1955
+ * @returns {Promise<void>}
1956
+ */
1957
+ async seeInClipboard(text) {
1958
+ const clipboard = await this.grabFromClipboard()
1959
+ return stringIncludes('clipboard').assert(text, clipboard)
1960
+ }
1961
+
1962
+ /**
1963
+ * Checks that the system clipboard is equal to the given text.
1964
+ *
1965
+ * ```js
1966
+ * I.click('Copy to clipboard');
1967
+ * I.seeClipboardEquals('https://codecept.io');
1968
+ * ```
1969
+ *
1970
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
1971
+ *
1972
+ * @param {string} text value to check.
1973
+ * @returns {Promise<void>}
1974
+ */
1975
+ async seeClipboardEquals(text) {
1976
+ const clipboard = await this.grabFromClipboard()
1977
+ return equals('clipboard').assert(clipboard, text)
1978
+ }
1979
+
1980
+ /**
1981
+ * Clears the system clipboard.
1982
+ *
1983
+ * ```js
1984
+ * I.clearClipboard();
1985
+ * I.seeClipboardEquals('');
1986
+ * ```
1987
+ *
1988
+ * @returns {Promise<void>}
1989
+ */
1990
+ async clearClipboard() {
1991
+ await this._grantClipboardAccess()
1992
+ await this._evaluate(clipboardExpression(writeClipboardScript, ''))
1993
+ }
1994
+
1995
+ /**
1996
+ * Grabs the text content of the system clipboard.
1997
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
1998
+ *
1999
+ * ```js
2000
+ * I.click('Copy to clipboard');
2001
+ * const url = await I.grabFromClipboard();
2002
+ * ```
2003
+ *
2004
+ * @returns {Promise<string>} the system clipboard contents.
2005
+ */
2006
+ async grabFromClipboard() {
2007
+ await this._grantClipboardAccess()
2008
+ const clipboard = await this._evaluate(clipboardExpression(readClipboardScript, CLIPBOARD_READ_TIMEOUT_MS))
2009
+ this.debugSection('Clipboard', clipboard)
2010
+ return clipboard
2011
+ }
2012
+
2013
+ /**
2014
+ * Brings the current target to front and grants it clipboard read/write access, so
2015
+ * `navigator.clipboard` does not reject with a permission or focus error. Failures are ignored:
2016
+ * a browser without `Browser.grantPermissions` surfaces its own error from the read instead.
2017
+ *
2018
+ * @protected
2019
+ */
2020
+ async _grantClipboardAccess() {
2021
+ await this.cdp.send('Page.bringToFront', {}, this.sessionId).catch(() => null)
2022
+ const origin = await this._evaluate('window.location.origin').catch(() => null)
2023
+ if (!origin || !origin.startsWith('http')) return
2024
+ await this.cdp.send('Browser.grantPermissions', { origin, permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'] }).catch(() => null)
2025
+ }
2026
+
1943
2027
  /**
1944
2028
  * Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
1945
2029
  * Filename is relative to the output folder.
@@ -8,6 +8,7 @@ import Locator from '../locator.js'
8
8
  import recorder from '../recorder.js'
9
9
  import store from '../store.js'
10
10
  import { checkFocusBeforeType, checkFocusBeforePressKey } from './extras/focusCheck.js'
11
+ import { CLIPBOARD_READ_TIMEOUT_MS, readClipboardScript, writeClipboardScript } from './extras/clipboard.js'
11
12
  import { includes as stringIncludes } from '../assert/include.js'
12
13
  import { urlEquals, equals } from '../assert/equal.js'
13
14
  import { empty } from '../assert/empty.js'
@@ -2667,6 +2668,49 @@ class Playwright extends Helper {
2667
2668
  return this.browserContext.clearCookies()
2668
2669
  }
2669
2670
 
2671
+ /**
2672
+ * {{> seeInClipboard }}
2673
+ */
2674
+ async seeInClipboard(text) {
2675
+ const clipboard = await this.grabFromClipboard()
2676
+ stringIncludes('clipboard').assert(text, clipboard)
2677
+ }
2678
+
2679
+ /**
2680
+ * {{> seeClipboardEquals }}
2681
+ */
2682
+ async seeClipboardEquals(text) {
2683
+ const clipboard = await this.grabFromClipboard()
2684
+ return equals('clipboard').assert(clipboard, text)
2685
+ }
2686
+
2687
+ /**
2688
+ * {{> grabFromClipboard }}
2689
+ */
2690
+ async grabFromClipboard() {
2691
+ await this._grantClipboardAccess()
2692
+ const clipboard = await this.page.evaluate(readClipboardScript, CLIPBOARD_READ_TIMEOUT_MS)
2693
+ this.debugSection('Clipboard', clipboard)
2694
+ return clipboard
2695
+ }
2696
+
2697
+ /**
2698
+ * {{> clearClipboard }}
2699
+ */
2700
+ async clearClipboard() {
2701
+ await this._grantClipboardAccess()
2702
+ return this.page.evaluate(writeClipboardScript, '')
2703
+ }
2704
+
2705
+ async _grantClipboardAccess() {
2706
+ await this.page.bringToFront().catch(() => {})
2707
+ if (this.options.browser !== 'chromium') return
2708
+ await this.page
2709
+ .context()
2710
+ .grantPermissions(['clipboard-read', 'clipboard-write'])
2711
+ .catch(() => {})
2712
+ }
2713
+
2670
2714
  /**
2671
2715
  * Executes a script on the page:
2672
2716
  *
@@ -9,6 +9,7 @@ import Locator from '../locator.js'
9
9
  import recorder from '../recorder.js'
10
10
  import store from '../store.js'
11
11
  import { checkFocusBeforeType, checkFocusBeforePressKey } from './extras/focusCheck.js'
12
+ import { CLIPBOARD_READ_TIMEOUT_MS, readClipboardScript, writeClipboardScript } from './extras/clipboard.js'
12
13
  import { includes as stringIncludes } from '../assert/include.js'
13
14
  import { urlEquals, equals } from '../assert/equal.js'
14
15
  import { empty } from '../assert/empty.js'
@@ -1968,6 +1969,55 @@ class Puppeteer extends Helper {
1968
1969
  return this.page.deleteCookie(cookie[0])
1969
1970
  }
1970
1971
 
1972
+ /**
1973
+ * {{> seeInClipboard }}
1974
+ */
1975
+ async seeInClipboard(text) {
1976
+ const clipboard = await this.grabFromClipboard()
1977
+ stringIncludes('clipboard').assert(text, clipboard)
1978
+ }
1979
+
1980
+ /**
1981
+ * {{> seeClipboardEquals }}
1982
+ */
1983
+ async seeClipboardEquals(text) {
1984
+ const clipboard = await this.grabFromClipboard()
1985
+ return equals('clipboard').assert(clipboard, text)
1986
+ }
1987
+
1988
+ /**
1989
+ * {{> grabFromClipboard }}
1990
+ */
1991
+ async grabFromClipboard() {
1992
+ await this._grantClipboardAccess()
1993
+ const clipboard = await this.page.evaluate(readClipboardScript, CLIPBOARD_READ_TIMEOUT_MS)
1994
+ this.debugSection('Clipboard', clipboard)
1995
+ return clipboard
1996
+ }
1997
+
1998
+ /**
1999
+ * {{> clearClipboard }}
2000
+ */
2001
+ async clearClipboard() {
2002
+ await this._grantClipboardAccess()
2003
+ return this.page.evaluate(writeClipboardScript, '')
2004
+ }
2005
+
2006
+ async _grantClipboardAccess() {
2007
+ await this.page.bringToFront().catch(() => {})
2008
+ let origin
2009
+ try {
2010
+ origin = new URL(this.page.url()).origin
2011
+ } catch (err) {
2012
+ return
2013
+ }
2014
+ if (!origin.startsWith('http')) return
2015
+ await this.page
2016
+ .browserContext()
2017
+ .overridePermissions(origin, ['clipboard-read', 'clipboard-write', 'clipboard-sanitized-write'])
2018
+ .catch(() => {})
2019
+ }
2020
+
1971
2021
  /**
1972
2022
  * If a function returns a Promise, tt will wait for its resolution.
1973
2023
  *
@@ -3717,4 +3767,3 @@ async function proceedSelect(context, el, option) {
3717
3767
 
3718
3768
  return this._waitForAction()
3719
3769
  }
3720
-
@@ -11,6 +11,7 @@ import { includes as stringIncludes } from '../assert/include.js'
11
11
  import { urlEquals, equals } from '../assert/equal.js'
12
12
  import store from '../store.js'
13
13
  import { checkFocusBeforeType, checkFocusBeforePressKey } from './extras/focusCheck.js'
14
+ import { CLIPBOARD_READ_TIMEOUT_MS, readClipboardScript, writeClipboardScript, clipboardAsyncScript } from './extras/clipboard.js'
14
15
  import output from '../output.js'
15
16
  const { debug } = output
16
17
  import { empty } from '../assert/empty.js'
@@ -2091,6 +2092,48 @@ class WebDriver extends Helper {
2091
2092
  return cookie[0]
2092
2093
  }
2093
2094
 
2095
+ /**
2096
+ * {{> seeInClipboard }}
2097
+ */
2098
+ async seeInClipboard(text) {
2099
+ const clipboard = await this.grabFromClipboard()
2100
+ return stringIncludes('clipboard').assert(text, clipboard)
2101
+ }
2102
+
2103
+ /**
2104
+ * {{> seeClipboardEquals }}
2105
+ */
2106
+ async seeClipboardEquals(text) {
2107
+ const clipboard = await this.grabFromClipboard()
2108
+ return equals('clipboard').assert(clipboard, text)
2109
+ }
2110
+
2111
+ /**
2112
+ * {{> grabFromClipboard }}
2113
+ */
2114
+ async grabFromClipboard() {
2115
+ await this._grantClipboardAccess()
2116
+ const result = (await this.browser.executeAsync(clipboardAsyncScript(readClipboardScript), CLIPBOARD_READ_TIMEOUT_MS)) || {}
2117
+ if (result.error) throw new Error(`Could not read the clipboard: ${result.error}`)
2118
+ this.debugSection('Clipboard', result.value)
2119
+ return result.value
2120
+ }
2121
+
2122
+ /**
2123
+ * {{> clearClipboard }}
2124
+ */
2125
+ async clearClipboard() {
2126
+ await this._grantClipboardAccess()
2127
+ const result = (await this.browser.executeAsync(clipboardAsyncScript(writeClipboardScript), '')) || {}
2128
+ if (result.error) throw new Error(`Could not write to the clipboard: ${result.error}`)
2129
+ }
2130
+
2131
+ async _grantClipboardAccess() {
2132
+ if (typeof this.browser.setPermissions !== 'function') return
2133
+ await this.browser.setPermissions({ name: 'clipboard-read' }, 'granted').catch(() => {})
2134
+ await this.browser.setPermissions({ name: 'clipboard-write' }, 'granted').catch(() => {})
2135
+ }
2136
+
2094
2137
  /**
2095
2138
  * {{> waitForCookie }}
2096
2139
  */
@@ -0,0 +1,31 @@
1
+ export const CLIPBOARD_READ_TIMEOUT_MS = 5000
2
+
3
+ export function readClipboardScript(timeout) {
4
+ if (!navigator.clipboard || !navigator.clipboard.readText) {
5
+ throw new Error('Clipboard API is not available on this page, it requires a secure context (https or localhost)')
6
+ }
7
+ return Promise.race([navigator.clipboard.readText(), new Promise((resolve, reject) => setTimeout(() => reject(new Error('timed out while reading the clipboard')), timeout))])
8
+ }
9
+
10
+ export function writeClipboardScript(text) {
11
+ if (!navigator.clipboard || !navigator.clipboard.writeText) {
12
+ throw new Error('Clipboard API is not available on this page, it requires a secure context (https or localhost)')
13
+ }
14
+ return navigator.clipboard.writeText(text)
15
+ }
16
+
17
+ export function clipboardExpression(script, arg) {
18
+ return `(${script.toString()})(${JSON.stringify(arg)})`
19
+ }
20
+
21
+ export function clipboardAsyncScript(script) {
22
+ return `
23
+ var done = arguments[arguments.length - 1]
24
+ var fail = function (err) { done({ error: (err && err.message) || String(err) }) }
25
+ try {
26
+ (${script.toString()})(arguments[0]).then(function (value) { done({ value: value }) }, fail)
27
+ } catch (err) {
28
+ fail(err)
29
+ }
30
+ `
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.2.0-beta.4",
3
+ "version": "4.2.0",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [
@@ -770,6 +770,32 @@ declare namespace CodeceptJS {
770
770
  * @returns Appium: support both Android and iOS
771
771
  */
772
772
  closeApp(): Promise<void>;
773
+ /**
774
+ * Clears the system clipboard.
775
+ *
776
+ * ```js
777
+ * I.clearClipboard();
778
+ * I.seeClipboardEquals('');
779
+ * ```
780
+ */
781
+ clearClipboard(): Promise<any>;
782
+ /**
783
+ * Grabs the text content of the system clipboard and returns it to test.
784
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
785
+ *
786
+ * ```js
787
+ * I.click('Copy to clipboard');
788
+ * let url = await I.grabFromClipboard();
789
+ * ```
790
+ *
791
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
792
+ * in Chromium-based browsers, where read access is granted automatically.
793
+ * @returns the system clipboard contents.
794
+ *
795
+ *
796
+ * Appium: support both Android and iOS
797
+ */
798
+ grabFromClipboard(): Promise<string>;
773
799
  /**
774
800
  * Appends text to a input field or textarea.
775
801
  * Field is located by name, label, CSS or XPath
@@ -2166,6 +2192,56 @@ declare namespace CodeceptJS {
2166
2192
  * @param [name = null] - (optional, `null` by default) cookie name
2167
2193
  */
2168
2194
  clearCookie(name?: string | null): Promise<void>;
2195
+ /**
2196
+ * Checks that the system clipboard contains the given text.
2197
+ *
2198
+ * ```js
2199
+ * I.click('Copy to clipboard');
2200
+ * I.seeInClipboard('https://codecept.io');
2201
+ * ```
2202
+ *
2203
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
2204
+ * @param text - value to check.
2205
+ */
2206
+ seeInClipboard(text: string): Promise<void>;
2207
+ /**
2208
+ * Checks that the system clipboard is equal to the given text.
2209
+ *
2210
+ * ```js
2211
+ * I.click('Copy to clipboard');
2212
+ * I.seeClipboardEquals('https://codecept.io');
2213
+ * ```
2214
+ *
2215
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
2216
+ * @param text - value to check.
2217
+ */
2218
+ seeClipboardEquals(text: string): Promise<void>;
2219
+ /**
2220
+ * Clears the system clipboard.
2221
+ *
2222
+ * ```js
2223
+ * I.clearClipboard();
2224
+ * I.seeClipboardEquals('');
2225
+ * ```
2226
+ */
2227
+ clearClipboard(): Promise<void>;
2228
+ /**
2229
+ * Grabs the text content of the system clipboard.
2230
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
2231
+ *
2232
+ * ```js
2233
+ * I.click('Copy to clipboard');
2234
+ * const url = await I.grabFromClipboard();
2235
+ * ```
2236
+ * @returns the system clipboard contents.
2237
+ */
2238
+ grabFromClipboard(): Promise<string>;
2239
+ /**
2240
+ * Brings the current target to front and grants it clipboard read/write access, so
2241
+ * `navigator.clipboard` does not reject with a permission or focus error. Failures are ignored:
2242
+ * a browser without `Browser.grantPermissions` surfaces its own error from the read instead.
2243
+ */
2244
+ protected _grantClipboardAccess(): Promise<any>;
2169
2245
  /**
2170
2246
  * Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
2171
2247
  * Filename is relative to the output folder.
@@ -5107,6 +5183,55 @@ declare namespace CodeceptJS {
5107
5183
  * @param [cookie = null] - (optional, `null` by default) cookie name
5108
5184
  */
5109
5185
  clearCookie(cookie?: string): Promise<any>;
5186
+ /**
5187
+ * Checks that the system clipboard contains the given text.
5188
+ *
5189
+ * ```js
5190
+ * I.click('Copy to clipboard');
5191
+ * I.seeInClipboard('https://codecept.io');
5192
+ * ```
5193
+ *
5194
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5195
+ * in Chromium-based browsers, where read access is granted automatically.
5196
+ * @param text - value to check.
5197
+ */
5198
+ seeInClipboard(text: string): Promise<any>;
5199
+ /**
5200
+ * Checks that the system clipboard is equal to the given text.
5201
+ *
5202
+ * ```js
5203
+ * I.click('Copy to clipboard');
5204
+ * I.seeClipboardEquals('https://codecept.io');
5205
+ * ```
5206
+ *
5207
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5208
+ * in Chromium-based browsers, where read access is granted automatically.
5209
+ * @param text - value to check.
5210
+ */
5211
+ seeClipboardEquals(text: string): Promise<any>;
5212
+ /**
5213
+ * Grabs the text content of the system clipboard and returns it to test.
5214
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
5215
+ *
5216
+ * ```js
5217
+ * I.click('Copy to clipboard');
5218
+ * let url = await I.grabFromClipboard();
5219
+ * ```
5220
+ *
5221
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5222
+ * in Chromium-based browsers, where read access is granted automatically.
5223
+ * @returns the system clipboard contents.
5224
+ */
5225
+ grabFromClipboard(): Promise<string>;
5226
+ /**
5227
+ * Clears the system clipboard.
5228
+ *
5229
+ * ```js
5230
+ * I.clearClipboard();
5231
+ * I.seeClipboardEquals('');
5232
+ * ```
5233
+ */
5234
+ clearClipboard(): Promise<any>;
5110
5235
  /**
5111
5236
  * Executes a script on the page:
5112
5237
  *
@@ -7188,6 +7313,55 @@ declare namespace CodeceptJS {
7188
7313
  * @param [cookie = null] - (optional, `null` by default) cookie name
7189
7314
  */
7190
7315
  clearCookie(cookie?: string): Promise<any>;
7316
+ /**
7317
+ * Checks that the system clipboard contains the given text.
7318
+ *
7319
+ * ```js
7320
+ * I.click('Copy to clipboard');
7321
+ * I.seeInClipboard('https://codecept.io');
7322
+ * ```
7323
+ *
7324
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7325
+ * in Chromium-based browsers, where read access is granted automatically.
7326
+ * @param text - value to check.
7327
+ */
7328
+ seeInClipboard(text: string): Promise<any>;
7329
+ /**
7330
+ * Checks that the system clipboard is equal to the given text.
7331
+ *
7332
+ * ```js
7333
+ * I.click('Copy to clipboard');
7334
+ * I.seeClipboardEquals('https://codecept.io');
7335
+ * ```
7336
+ *
7337
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7338
+ * in Chromium-based browsers, where read access is granted automatically.
7339
+ * @param text - value to check.
7340
+ */
7341
+ seeClipboardEquals(text: string): Promise<any>;
7342
+ /**
7343
+ * Grabs the text content of the system clipboard and returns it to test.
7344
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
7345
+ *
7346
+ * ```js
7347
+ * I.click('Copy to clipboard');
7348
+ * let url = await I.grabFromClipboard();
7349
+ * ```
7350
+ *
7351
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7352
+ * in Chromium-based browsers, where read access is granted automatically.
7353
+ * @returns the system clipboard contents.
7354
+ */
7355
+ grabFromClipboard(): Promise<string>;
7356
+ /**
7357
+ * Clears the system clipboard.
7358
+ *
7359
+ * ```js
7360
+ * I.clearClipboard();
7361
+ * I.seeClipboardEquals('');
7362
+ * ```
7363
+ */
7364
+ clearClipboard(): Promise<any>;
7191
7365
  /**
7192
7366
  * If a function returns a Promise, tt will wait for its resolution.
7193
7367
  *
@@ -9505,6 +9679,55 @@ declare namespace CodeceptJS {
9505
9679
  * @param [name = null] - cookie name.
9506
9680
  */
9507
9681
  grabCookie(name?: string): Promise<any>;
9682
+ /**
9683
+ * Checks that the system clipboard contains the given text.
9684
+ *
9685
+ * ```js
9686
+ * I.click('Copy to clipboard');
9687
+ * I.seeInClipboard('https://codecept.io');
9688
+ * ```
9689
+ *
9690
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9691
+ * in Chromium-based browsers, where read access is granted automatically.
9692
+ * @param text - value to check.
9693
+ */
9694
+ seeInClipboard(text: string): Promise<any>;
9695
+ /**
9696
+ * Checks that the system clipboard is equal to the given text.
9697
+ *
9698
+ * ```js
9699
+ * I.click('Copy to clipboard');
9700
+ * I.seeClipboardEquals('https://codecept.io');
9701
+ * ```
9702
+ *
9703
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9704
+ * in Chromium-based browsers, where read access is granted automatically.
9705
+ * @param text - value to check.
9706
+ */
9707
+ seeClipboardEquals(text: string): Promise<any>;
9708
+ /**
9709
+ * Grabs the text content of the system clipboard and returns it to test.
9710
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
9711
+ *
9712
+ * ```js
9713
+ * I.click('Copy to clipboard');
9714
+ * let url = await I.grabFromClipboard();
9715
+ * ```
9716
+ *
9717
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9718
+ * in Chromium-based browsers, where read access is granted automatically.
9719
+ * @returns the system clipboard contents.
9720
+ */
9721
+ grabFromClipboard(): Promise<string>;
9722
+ /**
9723
+ * Clears the system clipboard.
9724
+ *
9725
+ * ```js
9726
+ * I.clearClipboard();
9727
+ * I.seeClipboardEquals('');
9728
+ * ```
9729
+ */
9730
+ clearClipboard(): Promise<any>;
9508
9731
  /**
9509
9732
  * Waits for the specified cookie in the cookies.
9510
9733
  *
@@ -770,6 +770,36 @@ declare namespace CodeceptJS {
770
770
  * @returns Appium: support both Android and iOS
771
771
  */
772
772
  closeApp(): Promise<void>;
773
+ /**
774
+ * Clears the system clipboard.
775
+ *
776
+ * ```js
777
+ * I.clearClipboard();
778
+ * I.seeClipboardEquals('');
779
+ * ```
780
+ * @returns automatically synchronized promise through #recorder
781
+ *
782
+ *
783
+ * Appium: support both Android and iOS
784
+ */
785
+ clearClipboard(): void;
786
+ /**
787
+ * Grabs the text content of the system clipboard and returns it to test.
788
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
789
+ *
790
+ * ```js
791
+ * I.click('Copy to clipboard');
792
+ * let url = await I.grabFromClipboard();
793
+ * ```
794
+ *
795
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
796
+ * in Chromium-based browsers, where read access is granted automatically.
797
+ * @returns the system clipboard contents.
798
+ *
799
+ *
800
+ * Appium: support both Android and iOS
801
+ */
802
+ grabFromClipboard(): Promise<string>;
773
803
  /**
774
804
  * Appends text to a input field or textarea.
775
805
  * Field is located by name, label, CSS or XPath
@@ -2193,6 +2223,56 @@ declare namespace CodeceptJS {
2193
2223
  * @param [name = null] - (optional, `null` by default) cookie name
2194
2224
  */
2195
2225
  clearCookie(name?: string | null): Promise<void>;
2226
+ /**
2227
+ * Checks that the system clipboard contains the given text.
2228
+ *
2229
+ * ```js
2230
+ * I.click('Copy to clipboard');
2231
+ * I.seeInClipboard('https://codecept.io');
2232
+ * ```
2233
+ *
2234
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
2235
+ * @param text - value to check.
2236
+ */
2237
+ seeInClipboard(text: string): Promise<void>;
2238
+ /**
2239
+ * Checks that the system clipboard is equal to the given text.
2240
+ *
2241
+ * ```js
2242
+ * I.click('Copy to clipboard');
2243
+ * I.seeClipboardEquals('https://codecept.io');
2244
+ * ```
2245
+ *
2246
+ * Reading the clipboard requires a secure context (`https` or `localhost`).
2247
+ * @param text - value to check.
2248
+ */
2249
+ seeClipboardEquals(text: string): Promise<void>;
2250
+ /**
2251
+ * Clears the system clipboard.
2252
+ *
2253
+ * ```js
2254
+ * I.clearClipboard();
2255
+ * I.seeClipboardEquals('');
2256
+ * ```
2257
+ */
2258
+ clearClipboard(): Promise<void>;
2259
+ /**
2260
+ * Grabs the text content of the system clipboard.
2261
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
2262
+ *
2263
+ * ```js
2264
+ * I.click('Copy to clipboard');
2265
+ * const url = await I.grabFromClipboard();
2266
+ * ```
2267
+ * @returns the system clipboard contents.
2268
+ */
2269
+ grabFromClipboard(): Promise<string>;
2270
+ /**
2271
+ * Brings the current target to front and grants it clipboard read/write access, so
2272
+ * `navigator.clipboard` does not reject with a permission or focus error. Failures are ignored:
2273
+ * a browser without `Browser.grantPermissions` surfaces its own error from the read instead.
2274
+ */
2275
+ protected _grantClipboardAccess(): void;
2196
2276
  /**
2197
2277
  * Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
2198
2278
  * Filename is relative to the output folder.
@@ -5196,6 +5276,58 @@ declare namespace CodeceptJS {
5196
5276
  * @param [cookie = null] - (optional, `null` by default) cookie name
5197
5277
  */
5198
5278
  clearCookie(cookie?: string): void;
5279
+ /**
5280
+ * Checks that the system clipboard contains the given text.
5281
+ *
5282
+ * ```js
5283
+ * I.click('Copy to clipboard');
5284
+ * I.seeInClipboard('https://codecept.io');
5285
+ * ```
5286
+ *
5287
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5288
+ * in Chromium-based browsers, where read access is granted automatically.
5289
+ * @param text - value to check.
5290
+ * @returns automatically synchronized promise through #recorder
5291
+ */
5292
+ seeInClipboard(text: string): void;
5293
+ /**
5294
+ * Checks that the system clipboard is equal to the given text.
5295
+ *
5296
+ * ```js
5297
+ * I.click('Copy to clipboard');
5298
+ * I.seeClipboardEquals('https://codecept.io');
5299
+ * ```
5300
+ *
5301
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5302
+ * in Chromium-based browsers, where read access is granted automatically.
5303
+ * @param text - value to check.
5304
+ * @returns automatically synchronized promise through #recorder
5305
+ */
5306
+ seeClipboardEquals(text: string): void;
5307
+ /**
5308
+ * Grabs the text content of the system clipboard and returns it to test.
5309
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
5310
+ *
5311
+ * ```js
5312
+ * I.click('Copy to clipboard');
5313
+ * let url = await I.grabFromClipboard();
5314
+ * ```
5315
+ *
5316
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5317
+ * in Chromium-based browsers, where read access is granted automatically.
5318
+ * @returns the system clipboard contents.
5319
+ */
5320
+ grabFromClipboard(): Promise<string>;
5321
+ /**
5322
+ * Clears the system clipboard.
5323
+ *
5324
+ * ```js
5325
+ * I.clearClipboard();
5326
+ * I.seeClipboardEquals('');
5327
+ * ```
5328
+ * @returns automatically synchronized promise through #recorder
5329
+ */
5330
+ clearClipboard(): void;
5199
5331
  /**
5200
5332
  * Executes a script on the page:
5201
5333
  *
@@ -7366,6 +7498,58 @@ declare namespace CodeceptJS {
7366
7498
  * @param [cookie = null] - (optional, `null` by default) cookie name
7367
7499
  */
7368
7500
  clearCookie(cookie?: string): void;
7501
+ /**
7502
+ * Checks that the system clipboard contains the given text.
7503
+ *
7504
+ * ```js
7505
+ * I.click('Copy to clipboard');
7506
+ * I.seeInClipboard('https://codecept.io');
7507
+ * ```
7508
+ *
7509
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7510
+ * in Chromium-based browsers, where read access is granted automatically.
7511
+ * @param text - value to check.
7512
+ * @returns automatically synchronized promise through #recorder
7513
+ */
7514
+ seeInClipboard(text: string): void;
7515
+ /**
7516
+ * Checks that the system clipboard is equal to the given text.
7517
+ *
7518
+ * ```js
7519
+ * I.click('Copy to clipboard');
7520
+ * I.seeClipboardEquals('https://codecept.io');
7521
+ * ```
7522
+ *
7523
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7524
+ * in Chromium-based browsers, where read access is granted automatically.
7525
+ * @param text - value to check.
7526
+ * @returns automatically synchronized promise through #recorder
7527
+ */
7528
+ seeClipboardEquals(text: string): void;
7529
+ /**
7530
+ * Grabs the text content of the system clipboard and returns it to test.
7531
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
7532
+ *
7533
+ * ```js
7534
+ * I.click('Copy to clipboard');
7535
+ * let url = await I.grabFromClipboard();
7536
+ * ```
7537
+ *
7538
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7539
+ * in Chromium-based browsers, where read access is granted automatically.
7540
+ * @returns the system clipboard contents.
7541
+ */
7542
+ grabFromClipboard(): Promise<string>;
7543
+ /**
7544
+ * Clears the system clipboard.
7545
+ *
7546
+ * ```js
7547
+ * I.clearClipboard();
7548
+ * I.seeClipboardEquals('');
7549
+ * ```
7550
+ * @returns automatically synchronized promise through #recorder
7551
+ */
7552
+ clearClipboard(): void;
7369
7553
  /**
7370
7554
  * If a function returns a Promise, tt will wait for its resolution.
7371
7555
  *
@@ -9761,6 +9945,58 @@ declare namespace CodeceptJS {
9761
9945
  * @returns attribute value
9762
9946
  */
9763
9947
  grabCookie(name?: string): any;
9948
+ /**
9949
+ * Checks that the system clipboard contains the given text.
9950
+ *
9951
+ * ```js
9952
+ * I.click('Copy to clipboard');
9953
+ * I.seeInClipboard('https://codecept.io');
9954
+ * ```
9955
+ *
9956
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9957
+ * in Chromium-based browsers, where read access is granted automatically.
9958
+ * @param text - value to check.
9959
+ * @returns automatically synchronized promise through #recorder
9960
+ */
9961
+ seeInClipboard(text: string): void;
9962
+ /**
9963
+ * Checks that the system clipboard is equal to the given text.
9964
+ *
9965
+ * ```js
9966
+ * I.click('Copy to clipboard');
9967
+ * I.seeClipboardEquals('https://codecept.io');
9968
+ * ```
9969
+ *
9970
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9971
+ * in Chromium-based browsers, where read access is granted automatically.
9972
+ * @param text - value to check.
9973
+ * @returns automatically synchronized promise through #recorder
9974
+ */
9975
+ seeClipboardEquals(text: string): void;
9976
+ /**
9977
+ * Grabs the text content of the system clipboard and returns it to test.
9978
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
9979
+ *
9980
+ * ```js
9981
+ * I.click('Copy to clipboard');
9982
+ * let url = await I.grabFromClipboard();
9983
+ * ```
9984
+ *
9985
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9986
+ * in Chromium-based browsers, where read access is granted automatically.
9987
+ * @returns the system clipboard contents.
9988
+ */
9989
+ grabFromClipboard(): Promise<string>;
9990
+ /**
9991
+ * Clears the system clipboard.
9992
+ *
9993
+ * ```js
9994
+ * I.clearClipboard();
9995
+ * I.seeClipboardEquals('');
9996
+ * ```
9997
+ * @returns automatically synchronized promise through #recorder
9998
+ */
9999
+ clearClipboard(): void;
9764
10000
  /**
9765
10001
  * Waits for the specified cookie in the cookies.
9766
10002
  *