I want to select input based on type
equal to 'submit'
. Why does this selector not work?
await page.click('input[type="submit"')
For:
<input type="submit" value="submit" />
It's a typical selector in j@uery.
I want to select input based on type
equal to 'submit'
. Why does this selector not work?
await page.click('input[type="submit"')
For:
<input type="submit" value="submit" />
It's a typical selector in j@uery.
Share Improve this question edited Oct 29, 2018 at 18:31 Grant Miller 29.1k16 gold badges155 silver badges168 bronze badges asked Oct 29, 2018 at 8:32 Jessie ChanJessie Chan 111 gold badge1 silver badge2 bronze badges 1-
Can you explain what you mean by
it won't work
? – Md. Abu Taher Commented Oct 29, 2018 at 8:39
2 Answers
Reset to default 4You may need to wait for the element specified by the selector to be added to the DOM and visible before attempting to click it:
await page.waitForSelector('input[type="submit"]', {
visible: true,
});
Additionally, as AJC24 pointed out, you are in fact missing a right square bracket ]
, so the selector must be accurate before passing it to page.click()
:
await page.click('input[type="submit"]');
Looks like you have a typo in your selector to me. It should be:
await page.click('input[type="submit"]');
You were missing the ]
character at the end of your selector.