0

I have the following code:

 Process p = new Process();
 p.StartInfo.FileName = "iexplore.exe";
 p.StartInfo.CreateNoWindow = true;
 p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
 p.StartInfo.Arguments = "www.yandex.ru";
 p.Start();

After the call to p.Start() I need to simulate pressing a button on that page. How can I do this?

Picrofo Software
  • 5,475
  • 3
  • 23
  • 37
  • http://msdn.microsoft.com/en-us/library/aa752084%28v=VS.85%29.aspx – Hans Passant Jun 24 '13 at 18:02
  • Do you have to use internet explorer (for example you are loading a flash object or the site has some kind of ActiveX control) or can you just use a [WebClient that supports cookies](http://stackoverflow.com/questions/4740752/how-to-login-with-webclient-c-sharp/4740851#4740851)? – Scott Chamberlain Jun 24 '13 at 18:25
  • Thank you all guys. I am glad that your helped. I will try. Once again, thank you all :) – Karl Marx Jun 24 '13 at 18:35

3 Answers3

1

You need to run c:\program files\Microsoft\Internet Explorer\iexplore.exe or whatever your browser path is and then pass the URL as an argument into the process.start function.

For example

   Process.Start("IEXPLORE.EXE", "http://www.yandex.ru/");
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69
  • You are not completely understood. This my code. Process p = new Process(); p.StartInfo.FileName = "iexplore.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; p.StartInfo.Arguments = "www.yandex.ru"; p.Start(); But I need to click on the page. – Karl Marx Jun 24 '13 at 18:14
1

Check out WatIN which will help you automate all major HTML elements.

Example

The following example illustrates how to use WatiN to click on a button on a specific page according to its id attribute

[STAThread]
static void Main(string[] args)
{
    using (var _IExplore = new WatiN.Core.IE("http://www.yandex.ru"))
    {
        // _IExplore.Button(WatiN.Core.Find.ByName("nameOfButton")).Click(); //Clicks the button according to its name attribute
        _IExplore.Button(WatiN.Core.Find.ById("idOfButton")).Click(); //Clicks the button according to its id attribute
    }
}

Thank you,
Have a nice day :)

Picrofo Software
  • 5,475
  • 3
  • 23
  • 37
0

You can use the Internet Explorer COM connection. For example. And as @Hans Passant mentioned above, here is the documentation.

jle
  • 9,316
  • 5
  • 48
  • 67