Question

Say we have a generic website: google.com

Is there a way, from C# I can create an instance of internet explorer, enter text in to the google search textbox (this is just an example, the emphasis is on a named HTML textbox) and automate clicking the search button (again an example, the emphasis is on any named button)?

I appreciate Javascript is usually more appropriate for this type of stuff, but is it possible to do this from C#? I know an Internet Explorer instance can be created in .net, but I am unsure if you can "load" a webpage and then manipulate the webpage from a C# application

Was it helpful?

Solution

Take a look at Selenium you can get a .Net version from NuGet. It's commonly used for automating browser testing.

OTHER TIPS

An alternative to Selenium is the Telerik Testing Framework. It's free and if all you need to interact with is Internet Explorer, everything will be self-contained in this one library and you'll never need to leave .NET.

If you need to launch browsers other than Internet Explorer, this solution is a little more complicated because you'll need plugins installed into those other browsers before you're able to control them.

You probably won't need to do much more than the steps on the Getting Started page in order to accomplish what you're trying to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top