How to put text into input element in Pyppeteer
In Pyppeteer, if you have an input like this one:
<input id="myInput">
you can fill with text like abc123
by using page.type()
like in this snippet:
await page.type('#myInput', 'abc123')
Full example
This example fetches techoverflow.net and puts my search
into the search query input on the top right:
#!/usr/bin/env python3
import asyncio
from pyppeteer import launch
async def main():
browser = await launch()
page = await browser.newPage()
await page.goto('https://www.techoverflow.net')
# Fill text with input
await page.type('.search-form-input', 'my search')
# Make screenshot
await page.screenshot({'path': 'screenshot.png'})
# Cleanup
await browser.close()
asyncio.get_event_loop().run_until_complete(main())