|
|
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] = [] |
|
|
|
|
|
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 |
|
|
|