Pressing enter in puppeteer doesn\'t seem to have any effect. However, when I press other keys, it does what it should. This works:
await page.press(\'Arrow
short answer it might be a good idea to attach to the input control first :
await page.type('#inp_srch_box', 'add');
await page.type('#inp_srch_box',String.fromCharCode(13));
Long answer ...
cat package.json
{
"name": "test-open-login",
"version": "0.7.9",
"description": "an example test to test the login of the qto app",
"main": "test-open-login.test.js",
"scripts": {
"test": "mocha --recursive test",
"server": "http-server src"
},
"license": "BSD",
"devDependencies": {
"mocha": "5.0.1",
"puppeteer": "^2.1.0"
},
"dependencies": {
"chai": "^4.2.0",
"http-server": "^0.12.1",
"mocha": "5.0.1"
}
}
cat test/test-login.spec.js
const puppeteer = require('puppeteer');
async function main(){
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.setViewport({width: 1200, height: 720})
await page.goto('https://qto.fi/qto/login', { waitUntil: 'networkidle0' });
// wait until
await page.type('#email', 'test.anonymous.user@gmail.com');
//await page.type('#pass', 'secret');
// click and wait for navigation
await page.waitFor(1000);
//await frame.waitFor(1000);
await Promise.all([
page.click('#butLogin'),
page.waitForNavigation({ waitUntil: 'networkidle0' }),
]);
await page.type('#inp_srch_box', 'add');
await page.type('#inp_srch_box',String.fromCharCode(13));
}
main();