In an external webpage that I do not administrate, I have to fill a form that has no id or name. The "submit" button code looks like this:
<button type="submit" class="sui-AtomButton sui-AtomButton--primary sui-AtomButton--solid sui-AtomButton--center">
<span class="sui-AtomButton-inner">Save</span></button>
At first I tried a simple click like this:
await.page.click('[type="submit"]')
The button was clicked but it did not trigger the submition of the form (I also tried using "Enter" with the keyboard, but the result is the same).
Then, I tried to trigger the submit from the own form like this:
await page.evaluate(() => {
document.forms[0].submit();
})
and like this:
await page.evaluate(() => {
var f = document.forms[0]
Object.getPrototypeOf(f).submit.call(f);
})
and also like this:
await page.evaluate(() => {
document.forms[0].submit(function(event){
event.preventDefault();
});
})
In all the three cases the result is an error in the page.
What should I do? Thanks in advance.
See that in your JS code you don't have this:
e.preventDefault();
if you have this code then it will prevent the form to be submitted.