Search code examples
pythonseleniumalertmessagebox

Python Selenium multiple button message box


How can I press the yes button on a 3 button message box using python. my code below can only handle alert box.

alert = driver.switch_to_alert()
alert.accept()

see screenshot of the message box I get:

enter image description here

**Update: here is the source code of the popup msg:

function preSubmit() {
    var f = getForm();
    var confMsg= ("Do you want to set the WUC\'\s Scheduled End Date to this PCA\'\s Requested PC Date of "+f.pcAdj.value+" ?");
    var title = 'Confirm';
    test = vbMsg(confMsg, title);

    if(test == 6){
        f.adjPCDateFlag.value = true;   
        f.submitpca.value = true ;
        f.command.value = "doWucPcaView";
        doSubmit(f);
    }
    else if(test == 7){
        f.adjPCDateFlag.value = false;
        f.submitpca.value = true ;
        doSubmit(f);
    }
}

another issue I have is that this needs to open in firefox, and i am unable to press this and get the popup message


Solution

  • I can see that the alert you have received is a VB Script based pop-up and as far as I am aware "alert" in Selenium handles Javascript related pop-ups.

    In order to handle these kind of .net based alerts you have to either make use of Autoit or Winnium.