Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

MvcPages Quick Setup

Cezary Piątek edited this page May 16, 2017 · 10 revisions

Quick setup

  1. Create UnitTest project.
  2. Add reference to your Web project.
  3. Add reference to your favourite test freamework (NUnit, XUnit, MSTest etc.).
  4. Install Tellurium.MvcPages from Nuget
  5. Install selenium driver for your browser (See more details in Driver installation)
  6. Set "Copy to Output Directory" for each driver file to "Copy i newer".
  7. Create BrowserAdapterConfig. You can create BrowserAdapterConfig explicitly or from telluriumConfiguration section in app.config.
  8. Create BrowserAdapter using configuration.
  9. Perform UI interaction using BrowserAdapter instance.

Sample configuration in app.config

<configuration>
  <configSections>
    <section name="telluriumConfiguration" 
             type="Tellurium.MvcPages.Configuration.TelluriumConfigurationSection, Tellurium.MvcPages" />
  </configSections>
  <telluriumConfiguration
    browser="Chrome"
    driversPath="Drivers"
    pageUrl="http://localhost:51767"
    errorScreenshotsPath="c:\selenium\"
    />
</configuration>

Sample test with NUnit

[TestFixture]
public class SampleFormTest
{
    [Test]
    public void should_be_able_to_run_test_with_configuration_from_file()
    {
    	var testExecutionPath = TestContext.CurrentContext.TestDirectory;
        var browserAdapterConfig = BrowserAdapterConfig.FromAppConfig(testExecutionPath);
        using (var browser = BrowserAdapter.Create(browserAdapterConfig))
        {
            //Perform test
        }
    }
}

If you want to automatically save screenshot when exception occures use BrowserAdapter.Execute method to perform your page interaction code

[TestFixture]
public class SampleFormTest
{
    [Test]
    public void should_be_able_to_run_test_with_configuration_from_file()
    {
    	var testExecutionPath = TestContext.CurrentContext.TestDirectory;
        var browserAdapterConfig = BrowserAdapterConfig.FromAppConfig(testExecutionPath);
        BrowserAdapter.Execute(browserAdapterConfig, (browserAdapter) => {
        	    //Perform test
        });
    }
}

Clone this wiki locally