automa icon indicating copy to clipboard operation
automa copied to clipboard

how to handle the dialog popup on page load?

Open xjfnet opened this issue 3 years ago • 12 comments

the page popup a dialog on onload, how to handle the dialog?

<html>
<body>
<script>
alert('error');
</script>
</body>
</html>

xjfnet avatar Jun 06 '22 03:06 xjfnet

Add the Handle dialog block before the dialog occurs image

Kholid060 avatar Jun 06 '22 03:06 Kholid060

no effect

xjfnet avatar Jun 06 '22 03:06 xjfnet

there is a Login button on the page, click the Login button, the form post to the page itself, and then popup up a alert dialog to show error message

xjfnet avatar Jun 06 '22 03:06 xjfnet

And try to enable the Debug mode in the workflow settings image

Kholid060 avatar Jun 06 '22 03:06 Kholid060

no effect, even enable "Debug mode", and add "Handle Dialog" before "New Tab" and "Click Element"

xjfnet avatar Jun 06 '22 04:06 xjfnet

can we inject script and replace alert at dom loaded?

xjfnet avatar Jun 06 '22 04:06 xjfnet

no effect, even enable "Debug mode", and add "Handle Dialog" before "New Tab" and "Click Element"

This might be a bug, I'll look into it

can we inject script and replace alert at dom loaded?

Yes, by using the javascript code block

const alertWindow = window.alert;
window.alert = () => {
  window.alert = alertWindow;
}

automaNextBlock();

Kholid060 avatar Jun 06 '22 04:06 Kholid060

but your code above seems run just once, it need to auto run when page reload after click element

xjfnet avatar Jun 06 '22 04:06 xjfnet

Try this code

window.alert = () => {
  window.alert = true;
}

And in the javascript code block, enable the Execute every new tab image

Kholid060 avatar Jun 06 '22 05:06 Kholid060

no effect, it seems that the alert() run before the code above

and i found these of Chrome DevTools Protocol, Page.javascriptDialogClosed Page.javascriptDialogOpening Page.handleJavaScriptDialog

xjfnet avatar Jun 06 '22 17:06 xjfnet

no effect, it seems that the alert() run before the code above

and i found these of Chrome DevTools Protocol, Page.javascriptDialogClosed Page.javascriptDialogOpening Page.handleJavaScriptDialog

Automa is actually using that when the Debug mode is enabled, https://github.com/AutomaApp/automa/blob/340b66baac2fe6bc151286acaacaca2438c94325/src/background/workflowEngine/blocksHandler/handlerHandleDialog.js#L46-L56

Kholid060 avatar Jun 08 '22 01:06 Kholid060

addScriptToEvaluateOnNewDocument can do replace alert

xjfnet avatar Jun 08 '22 16:06 xjfnet

@Kholid060 I have the same issue, the "Handle dialog" doesn't work as expected with the next workflow: image

it is easy to reproduce here: https://the-internet.herokuapp.com/javascript_alerts

vleskiv avatar Aug 20 '22 20:08 vleskiv