Skip to content

Instantly share code, notes, and snippets.

@testautomationtribe
Created July 12, 2016 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testautomationtribe/5c235439c50ace62d0a56c99102d0a9f to your computer and use it in GitHub Desktop.
Save testautomationtribe/5c235439c50ace62d0a56c99102d0a9f to your computer and use it in GitHub Desktop.
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace TatAutomationFramework.Web
{
/// <summary>
///TestBase.cs Version 1.0
/// This attribute that marks a class that contains tests
/// and is inherited by any derived classes
/// This means we do not have to worry about this in our test classes
/// </summary>
[TestFixture]
public abstract class TestBase
{
internal static IWebDriver driver;
///<summary>
///Run Before every Test and setup Tests.
///</summary>
[SetUp]
public void TestSetup()
{
driver.Navigate().GoToUrl("http://127.0.0.1:4001/wordpress/");
}
/// <summary>
/// Runs after every Test and Cleans up Test.
/// </summary>
[TearDown]
public void TestCleanUp()
{
driver.Manage().Cookies.DeleteAllCookies();
}
/// <summary>
/// Begin execution of tests
/// </summary>
public static void BeginExecution()
{
driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20));
driver.Manage().Window.Maximize();
}
/// <summary>
/// Finish Execution of tests
/// </summary>
public static void ExitExecution()
{
if (driver != null)
{
driver.Quit();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment