Giter VIP home page Giter VIP logo

arana's Introduction

Araña web testing library

Araña ("spider" in Spanish) is a simple web testing library, written in C#. It can be used to integrate simple testing of web applications into unit testing, so the parts of your web application can be tested separately as well as how they work together.

Araña can follow links, post forms and, through simple CSS selectors, ensure that the content on the pages of your web application is what you expect, and thus can be tested with unit test assert statements.

Araña uses the HttpWebRequest and HttpWebResponse objects to fetch HTML documents and the Fizzler library to select elements from it to perform actions on.

Araña works seamlessly with all unit testing frameworks and can be used in all open source applications running on either Microsoft.NET or Mono. The CSS querying capabilities is built with jQuery in mind and will, where it fits, match the jQuery API.

Examples

Follow a link

The following example;

  1. Selects the a element with @class="first" inside the ul element with @id="menu"
  2. Follows it to the referenced URI (defined in the a@href attribute).
  3. Asserts that the title on the referenced page is equal to "Expected title".
// Create an Araña engine for a given web application
AranaEngine engine = new AranaEngine("http://example.com/");

// Select the anchor from the menu and follow it
engine.Select("ul#menu a.first").Follow();

// Assert that the expected title is correct on the resulting page
Assert.AreEqual("Expected title", engine.Select("title").InnerText);

Post a form

The following example;

  1. Selects the form element with @id="aspnetForm"
  2. Submits the form;
  3. Without following redirect (indicated by the false argument to the Submit() method)
  4. With the form elements named username and password set to the values specified in the given NameValueCollection.
  5. Asserts that the location being redirected to is equal to "/success".
// Create an Araña engine for a given web application
AranaEngine engine = new AranaEngine("http://example.com/");

// Select the form and submit it without following redirect and with the given values.
engine.Select("form#aspnetForm").Submit(false, new NameValueCollection
{
  {"username", "Administrator"},
  {"password", "2fmckX32a"},
});

// Assert that the location being redirected to is what we expect
Assert.AreEqual("/success", engine.Response.Location);

More examples

You can find more examples on the Examples page.

arana's People

Contributors

asbjornu avatar torstei avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.