You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ci.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,19 @@
1
-
# Getting started on CI
1
+
# Continuous integration.md
2
2
3
3
Playwright tests can be executed to run on your CI environments. To simplify this, we have created sample configurations for common CI providers that can be used to bootstrap your setup.
4
4
5
+
#### Contents
5
6
-[Docker](#docker)
6
-
-[GitHub](#github-actions)
7
+
-[GitHub Actions](#github-actions)
7
8
-[Azure Pipelines](#azure-pipelines)
8
9
-[Travis CI](#travis-ci)
9
10
-[CircleCI](#circleci)
10
11
-[AppVeyor](#appveyor)
11
12
12
13
Broadly, configuration on CI involves **ensuring system dependencies** are in place, **installing Playwright and browsers** (typically with `npm install`), and **running tests** (typically with `npm test`). Windows and macOS build agents do not require any additional system dependencies. Linux build agents can require additional dependencies, depending on the Linux distribution.
13
14
15
+
<br/>
16
+
14
17
## Docker
15
18
16
19
We have a [pre-built Docker image](docker/README.md) which can either be used directly, or as a reference to update your existing Docker definitions.
Playwright APIs that interact with elements accept selectors as the first argument, used to search for the element. Playwright can search for elements with CSS selectors, XPath, HTML attributes like `id`, `data-test-id` and text content.
112
+
Playwright can search for elements using CSS selectors, XPath selectors, HTML attributes like `id`, `data-test-id` and even text content.
113
113
114
-
Note that all selectors except for XPath pierce shadow DOM automatically.
114
+
You can explicitly specify the selector engine you are using or let Playwright detect it.
115
+
116
+
All selector engines except for XPath pierce shadow DOM by default. If you want to enforce regular DOM selection, you can use the `*:light` versions of the selectors. You don't typically need to though.
117
+
118
+
Learn more about selectors and selector engines [here](./selectors.md).
119
+
120
+
Some examples below:
121
+
122
+
```js
123
+
// Using data-test-id= selector engine
124
+
awaitpage.click('data-test-id=foo');
125
+
```
115
126
116
127
```js
117
-
//Auto-detected CSS notation
128
+
// CSS and XPath selector engines are automatically detected
118
129
awaitpage.click('div');
130
+
awaitpage.click('//html/body/div');
131
+
```
119
132
120
-
// Explicit CSS notation
121
-
awaitpage.click('css=div');
133
+
```js
134
+
// Find node by text substring
135
+
awaitpage.click('text=Hello w');
136
+
```
122
137
123
-
// Auto-detected XPath notation
138
+
```js
139
+
// Explicit CSS and XPath notation
140
+
awaitpage.click('css=div');
124
141
awaitpage.click('xpath=//html/body/div');
142
+
```
125
143
126
-
// Explicit XPath notation
127
-
awaitpage.click('//html/body/div');
144
+
```js
145
+
// Only search light DOM, outside WebComponent shadow DOM:
146
+
awaitpage.click('css:light=div');
147
+
```
128
148
129
-
// Auto-detected text notation
130
-
awaitpage.click('"Login"');
149
+
Selectors using the same or different engines can be combined using the `>>` separator. For example,
Copy file name to clipboardExpand all lines: docs/selectors.md
-46Lines changed: 0 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,49 +120,3 @@ Malformed selector starting with `"` is assumed to be a text selector. For examp
120
120
### id, data-testid, data-test-id, data-test and their :light counterparts
121
121
122
122
Attribute engines are selecting based on the corresponding atrribute value. For example: `data-test-id=foo` is equivalent to `css=[data-test-id="foo"]`, and `id:light=foo` is equivalent to `css:light=[id="foo"]`.
123
-
124
-
## Custom selector engines
125
-
126
-
Playwright supports custom selector engines, registered with [selectors.register(name, script[, options])](api.md#selectorsregistername-script-options).
127
-
128
-
Selector engine should have the following properties:
129
-
130
-
-`create` function to create a relative selector from `root` (root is either a `Document`, `ShadowRoot` or `Element`) to a `target` element.
131
-
-`query` function to query first element matching `selector` relative to the `root`.
132
-
-`queryAll` function to query all elements matching `selector` relative to the `root`.
133
-
134
-
By default the engine is run directly in the frame's JavaScript context and, for example, can call an application-defined function. To isolate the engine from any JavaScript in the frame, but leave access to the DOM, resgister the engine with `{contentScript: true}` option. Content script engine is safer because it is protected from any tampering with the global objects, for example altering `Node.prototype` methods. All built-in selector engines run as content scripts. Note that running as a content script is not guaranteed when the engine is used together with other custom engines.
135
-
136
-
An example of registering selector engine that queries elements based on a tag name:
137
-
```js
138
-
// Must be a function that evaluates to a selector engine instance.
139
-
constcreateTagNameEngine= () => ({
140
-
// Creates a selector that matches given target when queried at the root.
0 commit comments