Automate answer to javascript alert message


#1

Can any one help me with how to automate Kantu to answer webpage javascript OK/Cancel alert box?

Or is it possible to modify form button onclick action so I can get rid of that alert box in first place?


#2

Kantu clicks “OK” automatically, no additional code needed. Test macro:

{
  "CreationDate": "2018-7-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "id=iframeResult",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "/html/body/button",
      "Value": ""
    }
  ]
}

#3

Yes, but it won’t work with alert boxes.


#4

Your macro does not work (URL expired?). But when I test an alert box it works just fine:

{
  "CreationDate": "2018-7-10",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.quackit.com/javascript/javascript_alert_box.cfm",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "name=result1",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "Click Alert!",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "/html/body/input",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "link=JavaScript Examples",
      "Value": ""
    }
  ]
}

#5

I tried that with Firefox and Chrome, but both shows alert and wait for clicking it.