Selenium FileUpload accept()没有单击按钮 [英] Selenium FileUpload accept() is not clicking button
问题描述
已在IE中打开文件选择器对话框,
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版本11.2580.14393.0;
IE Version 11.2580.14393.0;
Windows Server 2016 Standard
Windows Server 2016 Standard
显示的对话框是选择要上传的文件",此对话框包含一个带有Combobox + Open按钮的File name文本框,以及一个带有SplitOpenControl的Open按钮,其中的选项为Open/Open只读或保存.与以前的版本一样.
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.
推荐答案
OAuth或单一登录用户凭据的Edge和Chrome版本83警报是Alert的特例.
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.
我无法找到与Windows Dialog交互的Selenium方法,因此使用
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()
这篇关于Selenium FileUpload accept()没有单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!