|
1 | 1 | # Part 2: First steps with Playwright
|
2 | 2 |
|
3 |
| -Part 2 of the workshop shows how to take your first steps with Playwright calls. |
| 3 | +Part 2 of the tutorial shows how to take your first steps with Playwright calls. |
4 | 4 | It will explain browsers, contexts, and pages.
|
5 | 5 | It will also cover basic Playwright API calls.
|
6 | 6 |
|
@@ -136,14 +136,15 @@ Out of the box, Playwright supports the following types of selectors:
|
136 | 136 | * N-th element
|
137 | 137 | * React
|
138 | 138 | * Vue
|
| 139 | +* ID attributes |
139 | 140 |
|
140 | 141 | Text and CSS selectors also pierce the Shadow DOM by default!
|
141 | 142 |
|
142 | 143 | In general, you should keep selectors as simple as possible.
|
143 | 144 | Try to stick to text, IDs, or CSS selectors.
|
144 | 145 | Use more complicated selectors only as necessary.
|
145 | 146 |
|
146 |
| -This workshop will not cover recommended practices for element selectors deeply. |
| 147 | +This tutorial will not cover recommended practices for element selectors deeply. |
147 | 148 | If you want to learn more about selectors,
|
148 | 149 | read the [Element selectors](https://playwright.dev/python/docs/selectors) page in the Playwright docs,
|
149 | 150 | or take the [Web Element Locator Strategies](https://testautomationu.applitools.com/web-element-locator-strategies/) course
|
@@ -175,6 +176,11 @@ Append the following line to the test case:
|
175 | 176 | page.fill('#search_form_input_homepage', 'panda')
|
176 | 177 | ```
|
177 | 178 |
|
| 179 | +> Since `search_form_input_homepage` is an ID, we could also use Playwright's |
| 180 | +> [ID attribute selector](https://playwright.dev/python/docs/selectors#id-data-testid-data-test-id-data-test-selectors): |
| 181 | +> |
| 182 | +> `page.fill('id=search_form_input_homepage', 'panda')` |
| 183 | +
|
178 | 184 | Using Selenium WebDriver, we would need to locate the element and then send the interaction to it.
|
179 | 185 | However, in Playwright, these two parts are combined into a single call.
|
180 | 186 | Furthermore, Playwright waits for the target element to be visible and editable before it attempts to enter the text.
|
@@ -222,4 +228,4 @@ Now, you should see the test actually perform the search!
|
222 | 228 | Navigation, input filling, and clicking are only three of many page interactions you can do with Playwright.
|
223 | 229 | Anything a user can do on a web page, Playwright can do as well.
|
224 | 230 | Check out the Playwright [Page](https://playwright.dev/python/docs/api/class-page) API to see *all* methods and attributes.
|
225 |
| -We will use more of these calls in the next workshop parts. |
| 231 | +We will use more of these calls in the next tutorial parts. |
0 commit comments