I'm making a python script that requests the user for their cookie through playwright webdriver
This is my dummy code
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=False)
context = await browser.new_context()
page = await context.new_page()
await page.goto('https://example.com')
print('Please log-in')
while True:
for i in (await context.cookies()):
if i['name'] == 'account_cookie':
return i['value']
asyncio.run(main())
You could use wait_for_function
:
await page.wait_for_function("document.cookie.includes('account_cookie')")