Click here to Skip to main content
13,452,126 members (52,234 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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

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

Help will be much appreciated!
Posted 14-Jan-13 5:25am
Updated 14-Jan-13 5:26am
PosiRob 14-Jan-13 12:25pm
Could you add to your question it's about web forms. I thought I could answer your question because in Winforms I know how to do it!
ShaiBen 16-Jan-13 4:22am
It's a native windows dialog (which was opened by Firefox), so I don't think it's a web form.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Try this WatiN[^]
Suvabrata Roy 14-Jan-13 23:28pm
Why this answer is down voted. WatiN is able to Handel dialog box.
ShaiBen 16-Jan-13 4:29am
I'm looking for a solution that does not involve more 3rd party apps, since I have already implemented all my testing framework with selenium.
but I was not the one downvoted your answer.
Suvabrata Roy 16-Jan-13 4:39am
Ok Dialog Popup : Link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180318.3 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100