New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Puppeteer page.select got error: Cannot read property 'indexOf' of undefined #3327
Comments
Hello @jennycai0807, I cannot reproduce this issue. I've run this code:
on https://try-puppeteer.appspot.com/ and I got expected result: Could you provide html or link to page you're testing on ? |
Here is the html:
The default value is "Please select", and the default value can't be selected. So when I tried page.type function, it didn't work. |
Oh, it’s providerSelector. I changed some text, but it doesn’t matter. |
I've created script based on HTML: One important thing is that there was Does script from my gist works for you? |
I used your script, it worked. But the problem is when I run the real test in my test web url, it shows the error: In the UI, the value is selected, but "Next" button is activated. Note: When I select the value from real UI, the "Next" button will be enabled, so I can go to next step. |
@jennycai0807 any chance you can share an HTML that reproduces the issue? If you can't share a link, a minified example would help a lot. |
Use this script can show the error, and also the language value isn't real selected (The whole page isn't updated to de_DE language) |
@jennycai0807 awesome, thanks. The website overrides the top-level This will be addressed with #2671 |
Hi @aslushnikov, how can I get the latest puppeteer version after you fix this issue? |
Can I ask another question about puppeteer? Or should I create a new issue Or feature request? |
Sure, I answered on SO. |
Can I manually update my puppeteer code to quickly fix this issue? Because I need to use page.select these days. |
@aslushnikov before you fix this bug, do I have any workaround to select it using puppeteer? |
I have used below workaround, and it worked:
|
This patch starts creating secondary DOMWorld for every connected page and switches `page.select()` to run inside the secondary world. Fix puppeteer#3327.
This patch starts creating secondary DOMWorld for every connected page and switches `page.select()` to run inside the secondary world. Fix #3327.
When I use page.select function, it got an error:
TypeError: Cannot read property 'indexOf' of undefined
My code is:
await page.select('#providerSelector', '101');
Then I use another way:
let selectElem = await page.waitForSelector("#providerSelector");
let optionElem = await page.waitForSelector("#providerSelector > option:nth-child(3)");
await page.evaluate((optionElem, selectElem) => {
optionElem.selected = true;
const event = new Event('change', {bubbles: true});
event.simulated=true;
selectElem.dispatchEvent(event);
}, optionElem, selectElem);
But still got the same error.
Is it a bug of Puppeteer?
Note: My Chromium Version 69.0.3452.0 (Developer Build) (64-bit)
If it's a puppeteer bug? How can I upgrade my puppeteer version?
The text was updated successfully, but these errors were encountered: