Skip to content

Commit 2814d1c

Browse files
authored
Replace discouraged PlayWright functions in our pytests (#8467)
* Replace page.click with page.locator.click * Replace page.expect_navigation with page.wait_for_url * Replace page.fill with locator.fill * Replace page.text_content with locator.text_content
1 parent 8d04b88 commit 2814d1c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

tests/suite/test_oidc.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,14 @@ def run_oidc(browser_type, ip_address, port):
224224
page = context.new_page()
225225

226226
page.goto("https://virtual-server-tls.example.com")
227-
page.wait_for_selector('input[name="username"]')
228-
page.fill('input[name="username"]', username)
229-
page.wait_for_selector('input[name="password"]', timeout=5000)
230-
page.fill('input[name="password"]', password)
231-
232-
with page.expect_navigation():
233-
page.click('button[type="submit"]')
234-
page.wait_for_load_state("load")
235-
page_text = page.text_content("body")
227+
228+
page.locator("input[name='username']").fill(username)
229+
page.locator("input[name='password']").fill(password)
230+
231+
page.locator('button[type="submit"]').click()
232+
page.wait_for_url("https://virtual-server-tls.example.com")
233+
234+
page_text = page.locator("body").text_content()
236235
fields_to_check = [
237236
"Server address:",
238237
"Server name:",

tests/suite/test_oidc_fclo.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,14 @@ def run_oidc_fclo(browser_type, ip_address, port):
238238
# Log in to keycloak via fclo one
239239

240240
page.goto("https://fclo-one.example.com")
241-
page.wait_for_selector('input[name="username"]')
242-
page.fill('input[name="username"]', username)
243-
page.wait_for_selector('input[name="password"]', timeout=5000)
244-
page.fill('input[name="password"]', password)
245241

246-
with page.expect_navigation():
247-
page.click('button[type="submit"]')
248-
page.wait_for_load_state("load")
249-
page_text = page.text_content("body")
242+
page.locator("input[name='username']").fill(username)
243+
page.locator("input[name='password']").fill(password)
244+
245+
page.locator('button[type="submit"]').click()
246+
page.wait_for_url("https://fclo-one.example.com")
247+
248+
page_text = page.locator("body").text_content()
250249
fields_to_check = [
251250
"Server address:",
252251
"Server name:",
@@ -259,15 +258,15 @@ def run_oidc_fclo(browser_type, ip_address, port):
259258
# Check that we're also logged in via fclo two
260259
page.goto("https://fclo-two.example.com")
261260
page.wait_for_load_state("load")
262-
page_text = page.text_content("body")
261+
page_text = page.locator("body").text_content()
263262

264263
for field in fields_to_check:
265264
assert field in page_text, f"'{field}' not found in page text on fclo two"
266265

267266
# Start the log out process, go to keycloak's logout page
268267
page.goto("https://keycloak.example.com/realms/master/protocol/openid-connect/logout")
269268
page.locator("#kc-logout").click()
270-
page_text = page.text_content("body")
269+
page_text = page.locator("body").text_content()
271270
fields_to_check = [
272271
"You are logging out from following apps",
273272
"fclo-one client name",

0 commit comments

Comments
 (0)