Automato for navigation in a WebForms application

3

Dear, it was not the first time nor last time that I needed to implement an automatic routine that accesses a Web site or system created in the WebForms platform to capture information.

It has been extremely costly to make any form of automation for capturing and automatically navigating this type of web application with only WebRequests (C #) and / or WebClient (C #).

Please note that here I am totally disregarding the possibility of using an InternetExplorer.Application since I do not intend to use objects that depend on the interface to execute (run on servers, services, etc.)

Is there any more practical way that I can not see?

    
asked by anonymous 04.04.2014 / 20:34

2 answers

3

You can also use Selenium with Selenium Toolkit for .NET .

Just as PhantomJs, quoted by Miguel Angelo, is a browser automation tool. From their homepage

EN:

  

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

PT:

  

Selenium automates browsers. This is it! What you do with this power is completely up to you.

Here is a link to the most commonly used commands: link

An example of its use, taken from the international OS: link

using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;

class GoogleSuggest
{
    static void Main(string[] args)
    {
        IWebDriver driver = new FirefoxDriver();

        //Notice navigation is slightly different than the Java version
        //This is because 'get' is a keyword in C#
        driver.Navigate().GoToUrl("http://www.google.com/");
        IWebElement query = driver.FindElement(By.Name("q"));
        query.SendKeys("Cheese");
        System.Console.WriteLine("Page title is: " + driver.Title);
        driver.Quit();
    }
}
    
04.04.2014 / 22:00
2

Use the PhantomJs

You can use PhantomJs to simulate a browser, and do almost anything with it:

>
  • Take screenshots

  • convert page to PDF

  • Navigation Automation

  • testing websites

The project uses the webkit code, and allows you to do various things using javascript scripts. No browser is required.

To use in C #

Just include the PhantomJs nuget package :

PM> Install-Package PhantomJS

I know it's not native to C #, but does it really matter. You can build real robots with that. Including robots that work in the production environment.

    
04.04.2014 / 20:52