init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import asyncio
|
||||
from playwright.async_api import async_playwright
|
||||
from browser import login, BASE, OUT
|
||||
|
||||
async def main():
|
||||
async with async_playwright() as p:
|
||||
browser = await p.chromium.launch()
|
||||
actx, alice, aerr = await login(browser, "alice@localhost", "alicepass", "omemoalice")
|
||||
bctx, bob, berr = await login(browser, "bob@localhost", "bobpass", "omemobob")
|
||||
# Let both browsers generate and publish their bundles
|
||||
await alice.wait_for_timeout(5000)
|
||||
await bob.wait_for_timeout(1000)
|
||||
print("alice device:", await alice.evaluate("new ChatOmemoStorage().getLocalRegistrationId()"))
|
||||
print("bob device:", await bob.evaluate("new ChatOmemoStorage().getLocalRegistrationId()"))
|
||||
|
||||
await alice.goto(BASE + "/chat/bob@localhost")
|
||||
await alice.wait_for_selector("#chat_textarea", timeout=15000)
|
||||
await alice.wait_for_timeout(2000)
|
||||
print("alice state before:", await alice.evaluate("Chat.getOmemoState()"))
|
||||
await alice.evaluate("ChatOmemo.enableContactState('bob@localhost', false)")
|
||||
await alice.wait_for_timeout(5000)
|
||||
print("alice state after:", await alice.evaluate("Chat.getOmemoState()"))
|
||||
await alice.fill("#chat_textarea", "This is a secret 🔐")
|
||||
await alice.press("#chat_textarea", "Enter")
|
||||
await alice.wait_for_timeout(3000)
|
||||
await alice.screenshot(path=f"{OUT}/omemo_1_alice.png")
|
||||
|
||||
await bob.goto(BASE + "/chat/alice@localhost")
|
||||
await bob.wait_for_selector("#chat_textarea", timeout=15000)
|
||||
await bob.wait_for_timeout(5000)
|
||||
await bob.screenshot(path=f"{OUT}/omemo_2_bob.png")
|
||||
texts = await bob.locator("#chat_widget .bubble p").all_inner_texts()
|
||||
print("bob last bubbles:", texts[-3:])
|
||||
for e in aerr + berr:
|
||||
print(e)
|
||||
await browser.close()
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user