I am developing an E2E test for my app. In order to step through the whole workflow and make sure it works from beginning to the end.
Now given a form with an autocomplete element:
I am able to type in the form but unable to select an option. And hence advance through the form. I have tried so far:
E.g. method 1 - clicking an option
...
await page.type('input[id=ac]', 'san fran', {delay: 100})
await page.mouse.click(65, 600);
...
E.g. method 2 - automating keys
...
await page.type('input[id=ac]', 'san fran', {delay: 100})
await page.focus("#ac");
await page.type(String.fromCharCode(40)); //down arrow
await page.type(String.fromCharCode(13)); //enter
...
I only saw one Stack Overflow answer that said there may be security restrictions but I can't confirm it by looking at any official documentation.
How can I select an autocomplete option?
Full Code:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('http://localhost:8080/#/');
...
await page.type('input[id=ac]', 'san fran', {delay: 100})
await page.mouse.click(65, 600);
...
})();