Skip to content

Commit edfaf3f

Browse files
committed
accessibility tree
1 parent 6e7283e commit edfaf3f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

examples/custom_graph_domtree.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,27 @@
145145
}
146146
}
147147

148-
result, execution_info = graph.execute({
149-
"user_prompt": "How many list items are there in the document?",
150-
"local_dir": str(subtree_dict_simple)
151-
})
152-
153-
# get the answer from the result
154-
result = result.get("answer", "No answer found.")
155-
print(result)
148+
from playwright.sync_api import sync_playwright, Playwright
149+
150+
def run(playwright: Playwright):
151+
chromium = playwright.chromium # or "firefox" or "webkit".
152+
browser = chromium.launch()
153+
page = browser.new_page()
154+
page.goto("https://www.wired.com/category/science/")
155+
#get accessibilty tree
156+
accessibility_tree = page.accessibility.snapshot()
157+
158+
result, execution_info = graph.execute({
159+
"user_prompt": "List me all the latest news with their description.",
160+
"local_dir": str(accessibility_tree)
161+
})
162+
163+
# get the answer from the result
164+
result = result.get("answer", "No answer found.")
165+
print(result)
166+
# other actions...
167+
browser.close()
168+
169+
with sync_playwright() as playwright:
170+
run(playwright)
171+

0 commit comments

Comments
 (0)