Spaces:
Sleeping
Sleeping
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() | |