Selenium FileUpload accept() is not clicking button

試著忘記壹切 提交于 2020-07-23 06:26:05

问题


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:


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()


来源:https://stackoverflow.com/questions/53313673/selenium-fileupload-accept-is-not-clicking-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!