Selenium FileUpload accept() is not clicking button

293 views Asked by At

Having opened the file chooser dialog in IE,

self.webDiver.switch_to_alert().accept()

Tried the above line but does not click the open button.

IE Version 11.2580.14393.0;

Windows Server 2016 Standard

The dialog that gets displayed is "Choose File to Upload", this dialog has a File name text box with a Combobox + Open button as well as an Open button that is a SplitButtonControl with options to Open/Open readonly or save as previous version.

1

There are 1 answers

0
dank8 On BEST ANSWER

Edge and chrome version 83 alerts for a OAuth or Single Sign on User Credentials are a special case of Alert.

Dialog window is not part of the Browser, its a Operating system dialog (some technicalities are glossed over here) and launches in a separate process.

I was unable to find a Selenium method for interacting with Windows Dialog so used python uiautomation for windows instead:

window2 = uiautomation.WindowControl(searchDepth=1, ClassName='Credential Dialog Xaml Host')
window2.SetActive()
window2.SendKeys('username{TAB}password')
window2.ButtonControl(searchDepth=10, Name='OK').Click()