Having trouble with page.type not typing all characters
See original GitHub issueHaving some issues where it seems this.page.type is not working properly and I can’t figure out why. It works 100% of the time in one of my tests, but I have a second test doing the same thing on a different page (only difference is the new page has more input fields) and it fails most of the time (but occasionally passes). Here’s an example of what I’m doing:
await this.page.type('[placeholder="Enter ID"]', myObj.id);
await this.page.waitForSelector(`input[value="${myObj.id}"]`);
await this.page.type('[placeholder="Enter Type"]', myObj.type);
await this.page.waitForSelector(`input[value="${myObj.type}"]`);
I have 11 total input fields that follow the above pattern on this page, the page that has never flaked out on me has only 6 input fields.
The problem is page.type doesn’t appear to be typing everything in myObj, for example myObj.type contains 10 random words, occasionally puppeteer seems to only type some of the characters contained in myObj.type, it sometimes cuts off in the middle of a word, other times it cuts off at the end of a word. The property that doesn’t type out completely is random every run, as is the number of characters it actually types out. It is not a character limit in the database or input field (I can manually type in significantly more without a problem and each time I run it cuts off at a different random point, sometimes as few as 5-6 characters, other times as many as 20 or so characters).
Is there any debugging methods that would help me figure this out? Console logging myObj shows the full text for every property, taking screenshots or running puppeteer outside of headless mode shows that it stops inputting characters at random times.
Additionally I’ve tried adding a delay option into my page.type calls and it seems to make the issue worse, typing only a single character into my first input field before breaking. It seems like it might be losing focus (when watching it in headless: false mode).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:51
- Comments:76 (16 by maintainers)
Top GitHub Comments
Here’s a patch to overcome this method until it is fixed:
await page.evaluate((text) => { (document.getElementById('my-input')).value = text; }, "text-to-inject");
Seems a lot of people are still seeing this. Can we re-open it?