-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup_flow_approval.py
37 lines (33 loc) · 1.5 KB
/
cleanup_flow_approval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import logging
import os
from playwright.sync_api import BrowserContext
APPROVAL_FLOW_TITLE = 'test_approval'
TEST_USER = os.environ['TEST_USER']
TEST_PWD = os.environ['TEST_PWD']
TEST_APPROVAL_PORTAL = os.environ['TEST_APPROVAL_PORTAL']
def test_cleanup_approval_flow(context: BrowserContext):
page = context.new_page()
page.goto(TEST_APPROVAL_PORTAL)
page.get_by_placeholder("Email, phone, or Skype").click()
page.get_by_placeholder("Email, phone, or Skype").fill(TEST_USER)
page.get_by_role("button", name="Next").click()
page.get_by_placeholder("Password").click()
page.get_by_placeholder("Password").fill(TEST_PWD)
page.get_by_role("button", name="Sign in").click()
page.get_by_role("button", name="Yes").click()
page.wait_for_load_state(state="networkidle", timeout=60000)
if page.get_by_role("button", name="Close").is_visible():
page.get_by_role("button", name="Close").click()
while True:
if len(page.get_by_role("button", name=APPROVAL_FLOW_TITLE).all()) > 0:
li = page.get_by_role("button", name=APPROVAL_FLOW_TITLE).first
title = li.text_content()
logging.info(f"Found {title}!")
li.click()
page.get_by_text("Select an option").click()
page.get_by_role("option", name="Approve").click()
page.get_by_role("button", name="Confirm").click()
page.get_by_role("button", name="Done").click()
logging.info(f"Cleanup {title}!")
else:
break