import asyncio from pyppeteer import launch async def main(): examURL = 'http://example.com' portalURL = 'http://192.168.8.254/portal/user-authen.php' browser = await launch() page = await browser.newPage() await page.goto(portalURL) user, passwd = '***', '***' await page.focus('#txtLogin') await page.keyboard.type(user, {'delay': 50}) await page.focus('#txtPasswd') await page.keyboard.type(passwd, {'delay': 50}) await page.click('#btnLogin') await page.waitForNavigation() await browser.close() asyncio.get_event_loop().run_until_complete(main())