We have a Powerapp that has a text box and a submission button. My goal is to control this app via pyppeteer to achieve some automation.
Let me preface this by saying that I know some python, but have never used pyppeteer before, and that I know almost nothing about CSS. Right now, all I'm trying to do is get to the text box, write some text, and screenshot the result to prove to myself that it's working:
async def main():
browser = await launch()
page = await browser.newPage()
await page.goto([redacted_powerapp_url])
await page.waitFor(10000)
await page.type ('.appmagic-textarea.mousetrap.block-undo-redo', 'Hello')
await page.waitFor(5000)
await page.screenshot({'path': [redacted_screenshot_path})
I use this function like so: asyncio.get_event_loop().run_until_complete(main())
Which produces this error about not finding the selector:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
asyncio.get_event_loop().run_until_complete(main())
File [my_redacted_python_path], line 653, in run_until_complete
return future.result()
File "<pyshell#3>", line 6, in main
await page.type ('.appmagic-textarea.mousetrap.block-undo-redo', 'Hello')
File [my_redacted_python_path], line 1517, in type
return await frame.type(selector, text, options, **kwargs)
File [my_redacted_python_path], line 660, in type
raise PageError('Cannot find {} on this page'.format(selector))
pyppeteer.errors.PageError: Cannot find .appmagic-textarea.mousetrap.block-undo-redo on this page
I've tried several different ways of typing what I think the selector is, including inspecting the text box in Chrome, right clicking the relevant section of source code, choosing "Copy Selector" and pasting that, but to no avail. I've done some reading about selectors on Mozilla's site, and I just can't see what I've got wrong here.