I'm not sure where to start trying to detect an active Alert(). The alert locks the page when active so you can't use the inspector in dev tools, and does not exist in the dom as an element when not active, because alerts are created by javacript....
I know that Kantu (a Selenium based chrome automation addon) gets around alerts by automatically clicking "OK" on alerts as default, then allowing users to override this default behaviour with a different click target, eg: chooseCancelOnNextConfirmation if required.
Because alerts block all interaction with the page until dismissed there is certainly logic in this approach.
If I could detect and target an active alert I am pretty sure:
Code: Select all
ChromeSetElementValue>session_id,AlertElement_1,\uE007