如何与c#中的对话窗口进行交互? [英] How To interact with a dialog window in c#?

查看:116
本文介绍了如何与c#中的对话窗口进行交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试编写自动化程序,用C#测试网页。

我正在使用selenium web驱动程序,但它无法与本机窗口进行交互。

代码需要通过与Dialog窗口交互来自动上传文件,

所以我正在尝试使用C#代码来控制对话框窗口。



我已设法使用以下代码获取窗口句柄:



Hi I''m trying to write automation that will test a web-page with C#.
I''m using selenium web driver but it cannot interact with native windows.
The code need to automatically upload a file by interacting with a Dialog window,
so I''m trying to use C# code to control a dialog window.

I have managed to get a handle on the window using the following code:

public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
public const int WM_SETTEXT = 0x000C;
private void ChooseFile()
{
    // retrieve the handler of the window
    int iHandle = FindWindow("#32770", "File Upload");

    if (iHandle > 0)
    {
       //Choose File - using a string with the file path
       //Press OK
    }
}





我接下来需要做的是选择要上传的文件然后按OK批准。



帮助将不胜感激!



What I need to do next is to choose the file to upload and then press OK to approve.

Help will be much appreciated!

推荐答案





试试这个 WatiN [ ^ ]


这篇关于如何与c#中的对话窗口进行交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆