How to use AutoIT for handling multiple authentication windows with different credentials?



  • I am writing the test script in java using selenium webDriver.

    I have a situation where while executing the test script different authentication windows will appear and might need different credentials.

    For example when I open a url, a 'Authentication Required' window appears. Say this wants "uid1" and "pass1" as credentials. And when another link on that page is clicked anther 'Authentication Required' window appears and this needs "uid2" and "pass2" as credentials. In both authentication windows the title is same but the text is different.

    How to handle this using AutoIT? Can anyone please post a sample code or guide me through this?



  • If the order in which you spawn the windows is known, can you capture the handle value from the first window and then assume that the second window is the one that doesn't match that handle.

    I am rusty on AutoIt so I didn't put any code, but I did use the oh so cool window info tool to get the values I would try to use. It's a life saver in situations like this.

    First window:

    >>>> Window <<<<
    Title:  Authentication Required
    Class:  MozillaDialogClass
    Position:   2376, 597
    Size:   453, 167
    Style:  0x16C80084
    ExStyle:    0x00000101
    Handle: 0x000000000004097E #this appears unique, but not predictable
    

    Second window:

    >>>> Window <<<<
    Title:  Authentication Required
    Class:  MozillaDialogClass
    Position:   2376, 597
    Size:   453, 167
    Style:  0x16C80084
    ExStyle:    0x00000101
    Handle: 0x000000000005097E #this appears unique, but not predictable
    

    Essentially first window == 0x000000000004097E , second window <> 0x000000000004097E

    Alternately, you can do each operation in a different browser and use the Title and/or Class to distinguish them.

    First Window in FireFox:

    >>> Window <<<<
    Title:  Authentication Required
    Class:  MozillaDialogClass 
    Position:   2387, 597
    Size:   432, 167
    Style:  0x16C80084
    ExStyle:    0x00000101
    Handle: 0x000000000004097E
    

    Second Window in Internet Explorer:

    >>>> Window <<<<
    Title:  Windows Security
    Class:  #32770
    Position:   2234, 634
    Size:   439, 253
    Style:  0x96C80A84
    ExStyle:    0x00010101
    Handle: 0x00000000000507EA 
    


Suggested Topics