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/core-concepts.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,18 +88,60 @@ frames can be accessed for interactions inside the frame.
88
88
89
89
```js
90
90
// To interact with elements in an iframe
91
-
constframe=page.frame('frame-name');
92
-
awaitframe.fill('#username-input');
91
+
constframe=page.frame('frame-login');
92
+
awaitframe.fill('#username-input', 'John');
93
93
```
94
94
95
95
<br/>
96
96
97
97
## Selectors
98
98
99
+
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.
100
+
101
+
Note that all selectors except for XPath pierce shadow DOM automatically.
102
+
103
+
```js
104
+
// Auto-detected CSS notation
105
+
awaitpage.click('div');
106
+
107
+
// Explicit CSS notation
108
+
awaitpage.click('css=div');
109
+
110
+
// Auto-detected XPath notation
111
+
awaitpage.click('xpath=//html/body/div');
112
+
113
+
// Explicit XPath notation
114
+
awaitpage.click('//html/body/div');
115
+
116
+
// Auto-detected text notation
117
+
awaitpage.click('"Login"');
118
+
119
+
// Explicit text notation
120
+
awaitpage.click('text="Login"');
121
+
```
122
+
123
+
Selectors using different engines can be combined using the `>>` separator. Learn more about selectors and selector engines [here](./selectors.md).
124
+
99
125
<br/>
100
126
101
127
## Auto-waiting
102
128
129
+
Actions like `click` and `fill` auto-wait for the element to be visible and actionable. For example, click will:
130
+
- wait for element with given selector to be in DOM
131
+
- wait for it to become displayed, i.e. not `display:none`,
132
+
- wait for it to stop moving, for example, until css transition finishes
133
+
- scroll the element into view
134
+
- wait for it to receive pointer events at the action point, for example, waits until element becomes non-obscured by other elements
135
+
136
+
137
+
```js
138
+
// Will wait for #search element to be in DOM
139
+
awaitpage.fill('#search', 'query');
140
+
141
+
// Will wait for it to stop animating and accept clicks
0 commit comments