Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

MARK OKAFOR
MARK OKAFOR
3,029 Points

web automation using c# console application

i have a coding challenge. How can i click on an element on a website from a c# console? I have launched a web browser and open the web page from the console but now the challenge is writing a code that will click on an element on the web page.

1 Answer

Steven Parker
Steven Parker
231,007 Points

I can think of two approaches to do this sort of thing. One would be to access the page using a browser, as you have done already, and use an interface library for the browser that allows you to control it through your program.

The other would be to not use a browser at all, and to make a connection directly to the web site much like you might do for "scraping" data. Then you can simulate the message the browser would send when someone clicks on the control element (most likely submitting a form).