Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the get_by_prompt example to have a visible result #98

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions examples/get_by_prompt/get_by_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from playwright.sync_api import sync_playwright

# Set the URL to the desired website
URL = "https://thinking-tester-contact-list.herokuapp.com/"
URL = "https://duckduckgo.com/"


def main():
Expand All @@ -15,12 +15,15 @@
# Navigate to the URL
page.goto(URL)

# Get the sign up button by the prompt text
sign_up_btn = page.get_by_prompt(prompt="Sign up button")
# Get the search bar with the prompt text
search_bar = page.get_by_prompt("the search bar")

# Click the sign up button if it exists
if sign_up_btn:
sign_up_btn.click()
# Fill out the search bar, if it exists
if search_bar:
search_bar.fill("AgentQL")

# Click the search button
page.get_by_prompt("the search button").click()

Check failure on line 26 in examples/get_by_prompt/get_by_prompt.py

View workflow job for this annotation

GitHub Actions / Pre-commit checks

"click" is not a known attribute of "None" (reportOptionalMemberAccess)

# Used only for demo purposes. It allows you to see the effect of the script.
page.wait_for_timeout(10000)
Expand Down
Loading