forked from PathOnAI/LiteWebAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_installation.py
31 lines (22 loc) · 926 Bytes
/
test_installation.py
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
from playwright.sync_api import sync_playwright
def test_google_search():
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
# Navigate to Google's homepage
page.goto('https://www.google.com')
# Wait for the search input (textarea) to appear
page.wait_for_selector('textarea[name="q"]')
# Type in a search query
page.fill('textarea[name="q"]', 'Playwright testing')
# Press Enter to perform the search
page.press('textarea[name="q"]', 'Enter')
# Wait for the search results to load
page.wait_for_selector('h3')
# Check if the first result contains the expected text
first_result = page.text_content('h3')
print(first_result)
assert 'Playwright' in first_result
browser.close()
if __name__ == "__main__":
test_google_search()