gpt4 book ai didi

c# - SendKeys 到 Windows 文件对话框

转载 作者:行者123 更新时间:2023-11-30 16:46:10 25 4
gpt4 key购买 nike

我想将字符串 ABC 发送到 Windows 文件对话框的输入字段。使用此代码行,我可以将焦点设置到正确的元素。我看到一个闪烁的光标。

var filedialogOverlay = drv.SwitchTo().ActiveElement();

但是下面的代码并没有将字符串写入元素。

Thread.Sleep(1000);
filedialogOverlay.SendKeys("ABC");

编辑:文件上传提示由我要测试的网站显示。由于黑盒测试,我看不到源代码。有没有分析GUI的工具?

当我右键单击输入元素时,我得到以下选项。

enter image description here

最佳答案

可以使用Windows窗体的SendKeys.SendWait

//Input the file path into the filename field:
SendKeys.SendWait(longfilepath);
//Input "Enter" key
SendKeys.SendWait(@"{Enter}");

https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=vs.110).aspx

关于c# - SendKeys 到 Windows 文件对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40892408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com