MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / renew_comb

Function renew_comb

webarena/browser_env/auto_login.py:61–104  ·  view source on GitHub ↗
(comb: list[str], auth_folder: str = "./.auth")

Source from the content-addressed store, hash-verified

59
60
61def renew_comb(comb: list[str], auth_folder: str = "./.auth") -> None:
62 context_manager = sync_playwright()
63 playwright = context_manager.__enter__()
64 browser = playwright.chromium.launch(headless=HEADLESS)
65 context = browser.new_context()
66 page = context.new_page()
67
68 if "shopping" in comb:
69 username = ACCOUNTS["shopping"]["username"]
70 password = ACCOUNTS["shopping"]["password"]
71 page.goto(f"{SHOPPING}/customer/account/login/")
72 page.get_by_label("Email", exact=True).fill(username)
73 page.get_by_label("Password", exact=True).fill(password)
74 page.get_by_role("button", name="Sign In").click()
75
76 if "reddit" in comb:
77 username = ACCOUNTS["reddit"]["username"]
78 password = ACCOUNTS["reddit"]["password"]
79 page.goto(f"{REDDIT}/login")
80 page.get_by_label("Username").fill(username)
81 page.get_by_label("Password").fill(password)
82 page.get_by_role("button", name="Log in").click()
83
84 if "shopping_admin" in comb:
85 username = ACCOUNTS["shopping_admin"]["username"]
86 password = ACCOUNTS["shopping_admin"]["password"]
87 page.goto(f"{SHOPPING_ADMIN}")
88 page.get_by_placeholder("user name").fill(username)
89 page.get_by_placeholder("password").fill(password)
90 page.get_by_role("button", name="Sign in").click()
91
92 if "gitlab" in comb:
93 username = ACCOUNTS["gitlab"]["username"]
94 password = ACCOUNTS["gitlab"]["password"]
95 page.goto(f"{GITLAB}/users/sign_in")
96 page.get_by_test_id("username-field").click()
97 page.get_by_test_id("username-field").fill(username)
98 page.get_by_test_id("username-field").press("Tab")
99 page.get_by_test_id("password-field").fill(password)
100 page.get_by_test_id("sign-in-button").click()
101
102 context.storage_state(path=f"{auth_folder}/{'.'.join(comb)}_state.json")
103
104 context_manager.__exit__()
105
106
107def get_site_comb_from_filepath(file_path: str) -> list[str]:

Callers 1

auto_login.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected