0

I have a good understanding of DOM+HTML etc but I'm new to c#, whats the best way currently of downloading then rendering (executing all javascript + DOM changes etc) and simulating user interaction with a webpage in c#?

I've seen HTML agility pack mentioned quite a few times but it doesn't look like its been updated since August 2012? Has anyone used this recently and encountered any problems? Does c# have anything built in for this?

Thanks!

Mr J
  • 2,655
  • 4
  • 37
  • 58
  • Are you just trying to automatically test a site? That's what I'm getting from the phrase "Simulating User Interaction with a webpage in c#" – JNYRanger Nov 12 '14 at 21:56
  • To cut a long story short I'm basically trying to get my app to control a webpage (click buttons, read links, read buttons) because the site our client wants the app to interact with has no API and they're unwilling to make one for now. – Mr J Nov 12 '14 at 23:51
  • ugh, that's going to be painful. There are lots of testing frameworks that are able to 'click' and perform actions on a website, but they aren't really for use in a production environment to actually perform real tasks. I think you're going to have a very difficult time implementing this. Is there any other route you can take to accomplish what you're trying to do? Most of the html-agility-pack is for parsing and manipulating the HTML and changing DOM, but not actually performing actions on it. – JNYRanger Nov 14 '14 at 00:26

1 Answers1

1

First of all HTMLAgilityPack it's not for simulating user interaction in a web page, HTMLAgilityPack is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...).

HTMLAgilityPack not support JavaScript, it's a very important step, because many developers get trouble with the full load of the page in the browser and the request made by HTMLAgilityPack or any library you use to make the request.

For user interaction, full load of the web page, web testing I strongly recommend you Selenium, Selenium automates browsers. Selenium has support for several programming languages (Java, C#, Ruby, Python, etc), you can read more in the above link with a very good documentation.

The only drawback of Selenium is its open a browser to make the work, but it can be simulated in some environments to run headless browser, you can read more about this in the following links :

I hope this help you

Community
  • 1
  • 1
Victor Sigler
  • 23,243
  • 14
  • 88
  • 105