This repository was archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
MvcPages Quick Setup
Cezary Piątek edited this page May 16, 2017
·
10 revisions
- Create UnitTest project.
- Add reference to your Web project.
- Add reference to your favourite test freamework (NUnit, XUnit, MSTest etc.).
- Install Tellurium.MvcPages from Nuget
- Install selenium driver for your browser (See more details in Driver installation)
- Set "Copy to Output Directory" for each driver file to "Copy i newer".
- Create BrowserAdapterConfig. You can create BrowserAdapterConfig explicitly or from telluriumConfiguration section in app.config.
- Create BrowserAdapter using configuration.
- 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
});
}
}