Spaces:
Sleeping
Sleeping
File size: 1,606 Bytes
4190c8f 7e6eae0 4190c8f 7e6eae0 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import re
from playwright.sync_api import expect, Page, Browser
def test_has_title(page: Page):
page.goto("http://localhost:8501")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("app"))
def test_get_started_link(browser: Browser):
for _ in range(1):
# create a new incognito browser context
context = browser.new_context()
# create a new page inside context.
page = context.new_page()
page.goto("http://localhost:8501")
# expect Sentiment Analysis Demo with AI Model Flags
locator = page.locator('.main')
expect(locator).to_contain_text("Sentiment Analysis Demo with AI Model Flags")
# screenshot
page.screenshot(path=f"test_get_started_link{_}.png")
# dispose context once it is no longer needed.
context.close()
def test_sentiment_tesst(page: Page):
page.goto("http://localhost:8501")
#Set Array of names to test
names = ["Happy", "Sad", "Angry", "Excited", "Fearful", "Confused", "Surprised", "Disgusted", "Calm", "Bored"]
for name in names:
page.get_by_label("Enter text for sentiment analysis:").fill("This is a test sentiment phrase.")
page.get_by_label("Enter your name").fill(name)
page.click('button:has-text("Analyze")')
# Screeshot
locator = page.locator('.main')
expect(locator).to_contain_text("Using model:")
expect(locator).to_contain_text("Sentiment:")
page.screenshot(path=f"test_sentiment_tesst_{name}.png")
# refresh page
page.reload()
|