New "Passwords..." pop-up in Big Sur causing scripting failure

A custom script I wrote that is used internally by Mac users to automate a connection process is now failing on Big Sur (yes, it’s taken this long for all the enterprise apps to be fully updated and approved by our IT department and allow us to install Big Sur… but I digress…)

The issue is that Big Sur seems to be adding a Passwords… pop-up button by default to a secure text field in one of the dialogs, as shown in the screenshot below:

This extra element causes the window detection logic in my script to fail.

I’ve tried, but I can’t find a good way to get information about this new extraneous Passwords… button so I can try and detect it in my script. As soon as I switch to UI Browser to find it, the Passwords… pop-up disappears (and the attributes of the dialog look like the script expects them to).

The check I’m using to detect this window opening is simply:

if button "OK" of window 2 of process theConnectorProcess exists then

which now fails because of the new Passwords… popup.

Has anyone dealt with this in Big Sur already? Any suggestions?

I think I’ve figured out a way to detect the Passwords… pop-up:

repeat 30 times
	set window2Subrole to the subrole of window 2 of process theConnectorProcess
	if window2Subrole is "AXStandardWindow" then
		-- still waiting for password dialog
		delay 0.5
	else if window2Subrole is "AXUnknown" then
		-- this is apparently the "Passwords..." pop-up in Big Sur
		-- send "escape" to get rid of it
		key code 53
	else if window2Subrole is "AXDialog" then
		-- this should be the password dialog we're waiting for
		exit repeat
	end if
end repeat

This logic is also backwards-compatible with pre-Big Sur installations, which is nice.

(If anybody has any better suggestions, I’m still interested in hearing them.)