Skip to content

Commit 5ff3a8e

Browse files
committed
rc5
1 parent 2c46918 commit 5ff3a8e

10 files changed

Lines changed: 131 additions & 6 deletions

File tree

banner.png

-905 KB
Binary file not shown.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
browsergym-core==0.1.0rc4
1+
browsergym-core==0.1.0rc5
22
english-words>=2.0.1
33
numpy>=1.14
44
requests>=2.31

src/browsergym/workarena/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0rc4"
1+
__version__ = "0.1.0rc5"
22

33
from browsergym.core.registration import register_task
44

src/browsergym/workarena/config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
# Knowledge base that is included with the benchmark
5353
KB_NAME = "General Knowledge"
54-
KB_FILEPATH = str(resources.files(data_files).joinpath("knowledge_base.json"))
54+
KB_FILEPATH = str(resources.files(data_files).joinpath("setup_files/knowledge_base.json"))
5555

5656
# Form tasks
5757
CREATE_CHANGE_REQUEST_CONFIG_PATH = str(
@@ -112,6 +112,13 @@
112112
WORKFLOWS = {
113113
"kb_publish": {
114114
"name": "WorkArena Auto-Publish",
115-
"update_set": str(resources.files(data_files).joinpath("kb_autopublish_workflow.xml")),
115+
"update_set": str(
116+
resources.files(data_files).joinpath("setup_files/kb_autopublish_workflow.xml")
117+
),
116118
}
117119
}
120+
121+
# Number of columns in the user list; used for setup
122+
EXPECTED_USER_COLUMNS_PATH = str(
123+
resources.files(data_files).joinpath("setup_files/expected_user_columns.json")
124+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[
2+
"user_name",
3+
"name",
4+
"email",
5+
"active",
6+
"sys_created_on",
7+
"sys_updated_on",
8+
"avatar",
9+
"building",
10+
"phone",
11+
"calendar_integration",
12+
"city",
13+
"sys_class_name",
14+
"company",
15+
"cost_center",
16+
"country",
17+
"sys_created_by",
18+
"date_format",
19+
"default_perspective",
20+
"department",
21+
"sys_domain",
22+
"sys_domain_path",
23+
"employee_number",
24+
"enable_multifactor_authn",
25+
"failed_attempts",
26+
"first_name",
27+
"gender",
28+
"home_phone",
29+
"internal_integration_user",
30+
"ldap_server",
31+
"preferred_language",
32+
"last_login",
33+
"last_login_time",
34+
"last_name",
35+
"location",
36+
"locked_out",
37+
"manager",
38+
"middle_name",
39+
"mobile_phone",
40+
"notification",
41+
"user_password",
42+
"password_needs_reset",
43+
"photo",
44+
"introduction",
45+
"roles",
46+
"schedule",
47+
"source",
48+
"state",
49+
"street",
50+
"sys_tags",
51+
"time_format",
52+
"time_zone",
53+
"title",
54+
"sys_updated_by",
55+
"sys_mod_count",
56+
"vip",
57+
"web_service_access_only",
58+
"zip"
59+
]

src/browsergym/workarena/data_files/kb_autopublish_workflow.xml renamed to src/browsergym/workarena/data_files/setup_files/kb_autopublish_workflow.xml

File renamed without changes.

src/browsergym/workarena/data_files/knowledge_base.json renamed to src/browsergym/workarena/data_files/setup_files/knowledge_base.json

File renamed without changes.

src/browsergym/workarena/install.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from playwright.sync_api import sync_playwright
77

88
from .api.utils import table_api_call
9-
from .config import KB_FILEPATH, KB_NAME, WORKFLOWS
9+
from .config import KB_FILEPATH, KB_NAME, EXPECTED_USER_COLUMNS_PATH, WORKFLOWS
1010
from .instance import SNowInstance
1111
from .utils import ui_login
1212

@@ -277,6 +277,60 @@ def install_workflows():
277277
browser.close()
278278

279279

280+
def display_all_columns(url: str):
281+
"""Display all columns in a given list view."""
282+
with sync_playwright() as playwright:
283+
instance = SNowInstance()
284+
browser = playwright.chromium.launch(headless=True, slow_mo=1000)
285+
page = browser.new_page()
286+
ui_login(instance, page)
287+
page.goto(instance.snow_url + url)
288+
frame = page.wait_for_selector("iframe#gsft_main").content_frame()
289+
frame.get_by_text("Personalize List").click()
290+
available_columns = frame.get_by_label("Available")
291+
available_columns.get_by_role("option").first.click()
292+
available_columns.get_by_role("option").last.click(modifiers=["Shift"])
293+
frame.get_by_text("Add").click()
294+
frame.click("#ok_button")
295+
296+
297+
def check_all_columns_displayed(url: str, expected_columns_path: str):
298+
"""Get the visible columns and checks that all expected columns are displayed."""
299+
with open(expected_columns_path, "r") as f:
300+
expected_columns = set(json.load(f))
301+
with sync_playwright() as playwright:
302+
instance = SNowInstance()
303+
browser = playwright.chromium.launch(headless=True, slow_mo=1000)
304+
page = browser.new_page()
305+
ui_login(instance, page)
306+
page.goto(instance.snow_url + url)
307+
iframe = page.frame("gsft_main")
308+
lst = iframe.locator("table.data_list_table")
309+
lst.wait_for()
310+
311+
# Validate the number of lists on the page
312+
lst = lst.nth(0)
313+
js_selector = f"gsft_main.GlideList2.get('{lst.get_attribute('data-list_id')}')"
314+
visible_columns = set(page.evaluate(f"{js_selector}.fields").split(","))
315+
316+
# check if expected columns is contained in the visible columns
317+
if not expected_columns.issubset(visible_columns):
318+
logging.info(
319+
f"Error setting up list at {url} \n Expected {expected_columns} columns, but got {visible_columns}."
320+
)
321+
return False
322+
logging.info(f"All columns properly displayed for {url}.")
323+
return True
324+
325+
326+
def setup_list_columns(url: str, expected_columns_path: str):
327+
"""Setup the list view to display the expected number of columns."""
328+
display_all_columns(url)
329+
assert check_all_columns_displayed(
330+
url, expected_columns_path
331+
), f"Error setting up list columns at {url}"
332+
333+
280334
def setup():
281335
"""
282336
Check that WorkArena is installed correctly in the instance.
@@ -285,6 +339,11 @@ def setup():
285339
# XXX: Install workflows first because they may automate some downstream installations
286340
setup_workflows()
287341
setup_knowledge_base()
342+
# Setup the user list columns by displaying all columns and checking that the expected number are displayed
343+
setup_list_columns(
344+
"/now/nav/ui/classic/params/target/sys_user_list.do%3Fsysparm_view%3D%26sysparm_userpref.sys_user_list.view%3D%26sysparm_userpref.sys_user.view%3D%26sysparm_query%3Dactive%253Dtrue%255Ecompany%253D81fd65ecac1d55eb42a426568fc87a63",
345+
EXPECTED_USER_COLUMNS_PATH,
346+
)
288347

289348

290349
def main():

src/browsergym/workarena/tasks/knowledge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class KnowledgeBaseSearchTask(AbstractServiceNowTask):
3333
def __init__(self, instance=None, fixed_config: dict = None) -> None:
3434
super().__init__(
3535
instance=instance,
36-
start_rel_url="/now/nav/ui/classic/params/target/knowledge_home_launcher.do",
36+
start_rel_url="/now/nav/ui/classic/params/target/%24knowledge.do",
3737
)
3838

3939
# Load the knowledge base and check its integrity

0 commit comments

Comments
 (0)