File size: 1,802 Bytes
495efa0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83e492d
495efa0
 
83e492d
495efa0
 
83e492d
495efa0
 
 
 
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
38
39
40
41
42
43
44
45
46
from typing import List, Dict

LAB_URL = "https://www.cloudskillsboost.google/course_templates/976/labs/550878"
SIGN_IN_URL = "https://accounts.google.com/signin/v2/identifier"
MARKETPLACE_URL = "https://console.cloud.google.com/marketplace/product/google/generativelanguage.googleapis.com"

def step(act, **kw) -> Dict:
    d = {"act": act}; d.update(kw); return d

def wait_css(sel: str, timeout: int = 25) -> Dict:
    return {"act": "wait", "by": "css", "sel": sel, "timeout": timeout}

def click_css(sel: str) -> Dict:
    return {"act": "click", "by": "css", "sel": sel}

def type_css(sel: str, text: str) -> Dict:
    return {"act": "type", "by": "css", "sel": sel, "text": text}

def screenshot(label: str) -> Dict:
    return {"act": "screenshot", "label": label}

def click_xpath(xpath: str) -> Dict:
    return {"act": "click", "by": "xpath", "sel": xpath}

def wait_xpath(xpath: str, timeout: int = 25) -> Dict:
    return {"act": "wait", "by": "xpath", "sel": xpath, "timeout": timeout}

def build_open_url_plan(url: str) -> List[Dict]:
    return [ step("get", sel=url), wait_css("body", 20), screenshot("opened") ]

def build_full_flow_plan(email: str, password: str, project_id: str) -> List[Dict]:
    steps: List[Dict] = []
    # NOTE: shortened for clarity; fill in with full plan steps from previous response
    steps += [
        step("get", sel="https://www.cloudskillsboost.google/users/sign_in"),
        wait_css("input[type=email]"),
        type_css("input[type=email]", email),
        click_css("button[type=submit],#identifierNext"),
        wait_css("input[type=password]"),
        type_css("input[type=password]", password),
        click_css("button[type=submit],#passwordNext"),
        wait_css("body", 40),
        screenshot("after_login")
    ]
    return steps