Skip to content

Commit 5e61f23

Browse files
author
George Griffiths
committed
update docs for codeceptjs
1 parent 0eebd7f commit 5e61f23

File tree

10 files changed

+129
-9
lines changed

10 files changed

+129
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
dist
33
.vscode
44
coverage
5-
.DS_Store
5+
.DS_Store
6+
**/output/**

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ This module exposes a playwright `selectorEngine`: https://github.com/microsoft/
3232
```javascript
3333
const { selectorEngine } = require("query-selector-shadow-dom/plugins/playwright");
3434
const playwright = require('playwright');
35-
...
36-
// NOTE: this api was change in playwright 0.12.0 to below in comments
37-
// https://github.com/microsoft/playwright/blob/master/docs/api.md#selectorsregistername-script
38-
// await selectors.register('shadow', createTagNameEngine);
39-
await playwright.selectors.register(selectorEngine, { name: 'shadow' })
35+
36+
await selectors.register('shadow', createTagNameEngine);
4037
...
4138
await page.goto('chrome://downloads');
4239
// shadow= allows a css query selector that automatically pierces shadow roots.

codecept.conf.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { setHeadlessWhen } = require('@codeceptjs/configure');
2+
3+
// turn on headless mode when running with HEADLESS=true environment variable
4+
// HEADLESS=true npx codecept run
5+
setHeadlessWhen(process.env.HEADLESS);
6+
7+
exports.config = {
8+
tests: 'test/codeceptjs/*.test.js',
9+
output: './output',
10+
helpers: {
11+
Playwright: {
12+
url: 'http://localhost',
13+
show: true,
14+
browser: 'chromium'
15+
}
16+
},
17+
include: {
18+
I: './steps_file.js'
19+
},
20+
bootstrap: null,
21+
mocha: {},
22+
name: 'query-selector-shadow-dom',
23+
plugins: {
24+
retryFailedStep: {
25+
enabled: true
26+
},
27+
screenshotOnFail: {
28+
enabled: true
29+
}
30+
}
31+
}

examples/playwright/custom-engine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { selectorEngine } = require("query-selector-shadow-dom/plugins/playwright
22
const playwright = require('playwright')
33

44
const main = async () => {
5-
await playwright.selectors.register(selectorEngine, { name: 'shadow' })
5+
await playwright.selectors.register('shadow', selectorEngine)
66

77
const browser = await playwright.chromium.launch({ headless: false})
88
const context = await browser.newContext({ viewport: null })

jsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true
4+
}
5+
}

plugins/codeceptjs/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Goal/Example: To be able to write a test that works easily with shadow dom web c
1010
See Issues for what currently works and what doesn't
1111

1212
```javascript
13-
const playwright = require("playwright");
14-
1513
Feature("The chrome downloads page");
1614
Scenario("Can interact with the search box", async I => {
1715
I.amOnPage("chrome://downloads");

steps.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference types='codeceptjs' />
2+
type steps_file = typeof import('./steps_file.js');
3+
4+
declare namespace CodeceptJS {
5+
interface SupportObject { I: CodeceptJS.I }
6+
interface CallbackOrder { [0]: CodeceptJS.I }
7+
interface Methods extends CodeceptJS.Playwright {}
8+
interface I extends ReturnType<steps_file> {}
9+
namespace Translation {
10+
interface Actions {}
11+
}
12+
}

steps_file.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// in this file you can append custom step methods to 'I' object
2+
3+
module.exports = function() {
4+
return actor({
5+
6+
// Define custom steps here, use 'this' to access default methods of I.
7+
// It is recommended to place a general 'login' function here.
8+
9+
});
10+
}

test/codeceptjs/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
CodeceptJS functions to test:
2+
3+
appendField
4+
attachFile
5+
checkOption
6+
clearField
7+
click
8+
clickLin
9+
dontSee
10+
dontSeeCheckboxIsChecked
11+
dontSeeCookie
12+
dontSeeCurrentUrlEquals
13+
dontSeeElement
14+
dontSeeElementInDOM
15+
dontSeeInField
16+
doubleClick
17+
dragAndDrop
18+
dragSlider
19+
fillField
20+
forceClick
21+
grabAttributeFrom
22+
grabCssPropertyFrom
23+
grabDataFromPerformanceTiming
24+
grabElementBoundingRect
25+
grabHTMLFrom
26+
grabNumberOfVisibleElements
27+
grabPageScrollPosition
28+
grabTextFrom
29+
grabValueFrom
30+
moveCursorTo
31+
openNewTab
32+
pressKey
33+
pressKeyDown
34+
pressKeyUp
35+
rightClick
36+
scrollPageToBottom
37+
scrollPageToTop
38+
scrollTo
39+
see
40+
seeAttributesOnElements
41+
seeCheckboxIsChecked
42+
seeCssPropertiesOnElements
43+
seeElement
44+
seeElementInDO
45+
seeInField
46+
seeNumberOfElements
47+
seeNumberOfVisibleElements
48+
seeTextEquals
49+
selectOptio
50+
uncheckOptio
51+
waitForClickable
52+
waitForDetached
53+
waitForElement
54+
waitForEnabled
55+
waitForInvisible
56+
waitForText
57+
waitForValue
58+
waitForVisible
59+
waitNumberOfVisibleElements
60+
waitToHide
61+
waitUntil

test/codeceptjs/components.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Feature('components');
2+
3+
Scenario('test something', (I) => {
4+
5+
});

0 commit comments

Comments
 (0)