AutomationTools 1.1.8
dotnet add package AutomationTools --version 1.1.8
NuGet\Install-Package AutomationTools -Version 1.1.8
<PackageReference Include="AutomationTools" Version="1.1.8" />
paket add AutomationTools --version 1.1.8
#r "nuget: AutomationTools, 1.1.8"
// Install AutomationTools as a Cake Addin #addin nuget:?package=AutomationTools&version=1.1.8 // Install AutomationTools as a Cake Tool #tool nuget:?package=AutomationTools&version=1.1.8
Alaska ITS QE Automation Tools
The information in this document is to provide an overview of the available functionality within this package. It was designed for Crew Tools API and UI Automation but can easily be applied to any automation portfolio.
Quick Links
What's New?
- Here you will find the latest updates.
Key Features
Below are the essential classes of this library, commonly used functions from those classes, and a brief explanation of their use cases. Please use these functions when ever possbile. It will save time in test writing.
Shared (API and UI) Tools
- Automation Logger
- AddToLog()
- Add a message to the log. This can be any information that needs to be logged. An enum can be passed to make it a warning message or error message, though the two below functions are preferred.
// Log test data AutomationLogger.AddToLog($"Testing using: {randomEvent}");
- LogWarning()
- Log a warning, this should not be used for validation logging.
- LogError()
- Log an error. This should be used for any condition that would indicate a test/feature failure.
AutomationLogger.LogError($"{eventDB} not found in DB");
- GetPST()
- Returns the current time in PST timezone, most applications need PST time, all logs are in PST time.
- SetBaseURL()
- This is used in the construction of an API controller in order to set the base URL of an API in the logger.
public CreamController(APIConfigs apiConfigs) : base(apiConfigs) { AutomationLogger.SetBaseURL(apiConfigs.BaseURL); AutomationLogger.AddToLog("Cream Controller created"); }
- SetDBType()
- This is used in the construction of a DB controller in order to set the type of database that's being used.
public CreamDB(string connectionString) { AutomationLogger.AddToLog("Opening Cream DB connection"); AutomationLogger.SetDBType("MS-SQL"); ConnectionString = connectionString; ModelGenerator = new SQLModelGenerator(); QueryFileName = "DatabaseQueryMapping"; }
- ConfigureLogger()
- This is a required setup function. Pass the name of the Application, the testing type (BVT, Smoke, etc.) and the environment (QA, Test, etc.).
public void Setup() { RandomizerTool = new AutomationRandomizerTools(); CreamHelper = new CreamHelper(); AutomationLogger.ConfigureLogger( appName: "Cream", testType: TestType.Functional, environment: TestContext.Parameters.Get("Env") ?? string.Empty); }
- ReconfigureLogger()
- This is used when comparing two different API environments. Example: (QA and Production) This is for logging clarity only.
// Reconfigure the logger for Production AutomationLogger.ReconfigureLogger();
// Reconfigure the logger for QA AutomationLogger.ReconfigureLogger("QA");
- LogTestResult()
- This is a required test completion function. Pass the name of the test function, true or false, and the Automation Core Driver object reference where appropriate (UI testing only).
finally { // Log test result AutomationLogger.LogTestResult(System.Reflection.MethodBase.GetCurrentMethod().Name, testPassed); // Assert test passed Assert.IsTrue(testPassed); }
- TestConditionsNotMet()
- This can be used to show that conditions for a test are not met. This should be used sparingly. An option message can be added to explain.
AutomationLogger.TestConditionsNotMet($"No data recovered from GetCrewInfo endpoint for FA with Id: {randomFA.GetValueByAttributeName("crewId")}");
- NoErrorsPresent()
- This is an essential function. API helper functions should return a boolean using this function.
return AutomationLogger.NoErrorsPresent();
- CatchException()
- This is an essential function. Will log any exception including an Inner Exception if one exists. Use with all test executions.
catch (Exception ex) { // Catch any unhandled exceptions that may occur AutomationLogger.CatchException(System.Reflection.MethodBase.GetCurrentMethod()!.Name, ex); }
- LogDBQuery()
- Log a database query. This facilites manual verification.
var sqlQuery = AutomationSQLTools.GetStoredQuery( filename: QueryFileName!, queryName: System.Reflection.MethodBase.GetCurrentMethod()!.Name); AutomationLogger.LogDBQuery(sqlQuery.Replace("@evtdtl_id", evtdtl_id));
- LogValueMismatch()
- This is an essential function. When two objects are not equal, pass the objects(two strings, two ints, a string and an int, etc.) and their sources (DB and API, QA and Production, etc.) and the column name to this for logging. This is a boiler plate function and will work with any object type.
if (!currentEvent.Reason!.StringsMatch(eventDB.Evt_code!)) { AutomationLogger.LogValueMismatch( object1: eventDB.Evt_code!, object2: currentEvent.Reason, source1: "Cream DB", source2: "Cream API", fieldName: "Event Code"); }
- AddToLog()
- Randomizer Tool
- GetRandomDate()
- Gets a random date between the base date and today. Default base date is 1/1/2000.
- GetRandomFutureDate()
- Gets a random date in the future. Optional variables can be supplied to adjust the range.
- GetRandomDateInRange()
- Returns a random date between two DateTime objects, two strings, or one of each. If a non-datetime string is provided, returns DateTime.MinValue.
// get current PST time var now = AutomationLogger.GetPST(); // get random start date up to 6 weeks prior var startDate = RandomizerTool!.GetRandomDateInRange(now.AddDays(-42), now); // get random end date up to 17 weeks later var endDate = RandomizerTool.GetRandomDateInRange(now, now.AddDays(7 * 17));
- GetRandomString()
- Creates a pseudo random string. Default length is 10 characters and numbers are inlcuded by default.
// create random meta data var metaData = new Dictionary<string, string> { { $"{RandomizerTool.GetRandomString(10, false)}", $"{RandomizerTool.GetRandomString(16, false)}" }, { $"{RandomizerTool.GetRandomString(10, false)}", $"{RandomizerTool.GetRandomString(16, false)}" } };
- GetRandomTime()
- GetRandomObjectFromCollection()
- This will select a random object from the supplied collection. Works with Lists and Arrays.
- A string array can also be provided containing field names that must not be null when selecting a random entry.
// Fetch a random entry from the list var randomEvent = RandomizerTool!.GetRandomObjectFromCollection(events!);
- GetRandomDoubleAsString()
- GetRandomDate()
- Extensions
- IsNullOrEmpty()
- This function will return true if a string is empty, a collection is empty, or any object is null.
// Validate file exists in DB if (!documentData.IsNullOrEmpty())
- DateFormat()
- This function takes in a string and will return a date string in the supplied format if the string is a valid DateTime string, otherwise, it returns an empty string or the original string.
// past month will only fetch data from DB and current will fetch from FTSA Prod api as well as Firefly DB if (Convert.ToDateTime(startDate.DateFormat("yyyy-MM")) >= Convert.ToDateTime(currentDate))
- DatesMatch()
- This function has four variants:
- Compare two strings
- Compare a DateTime object and a string
- Compare a string and a DateTime object
- Compare two DateTime objects
- It will return true if both dates match, time is not checked by default but can be if desired.
if (!auth.Auth_last_modified_datetime!.DatesMatch(currentAPI.Auth_last_modified_datetime!)) { AutomationLogger.LogValueMismatch( object1: auth.Auth_last_modified_datetime!, object2: currentAPI.Auth_last_modified_datetime, source1: "Cream DB", source2: "Cream API", fieldName: "Auth_last_modified_datetime"); }
- This function has four variants:
- StringsMatch()
- This function will return true if two strings match. Case is not considered by default but can be if desired.
if (!auth.Auth_last_modified_by!.StringsMatch(currentAPI.Auth_last_modified_by!)) { AutomationLogger.LogValueMismatch( object1: auth.Auth_last_modified_by!, object2: currentAPI.Auth_last_modified_by, source1: "Cream DB", source2: "Cream API", fieldName: "Auth_last_modified_by"); }
- StringifyDictionary()
- This function converts a Dictionary of type <string, string> into a JSON friendly string.
// convert the supplied meta data into a JSON friendly string var keyValues = Extensions.StringifyDictionary(metaData);
- CombineDictionaries()
- This combines two Dictionaries into one. This has only been tested with <string, string> dictionaries.
// add to the current metadata Extensions.CombineDictionaries(requestSearch.DocumentMetadata, entries);
- DictionariesMatch()
- This returns true if two dictionaries match completely. This has only been tested with <string, string> dictionaries.
- CompareBools()
- Accepts any combination of booleans, ints, and string and returns true if they match.
if (!item.IsProtected.CompareBools(currentDocument.Is_protected)) { AutomationLogger.LogValueMismatch( object1: item.IsProtected, object2: currentDocument.Is_protected, source1: "Crew Files API", source2: "Crew Files DB", fieldName: "IsProtected"); }
- IsNullOrEmpty()
- Encryption
- SQL Model Generator
- The parameters are the model type and the SQL data reader.
- Reader options:
- SQLDataReader
- DB2DataReader
- OracleDataReader
- Example usage:
connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { getScheduledClassesDbData.Add(ModelGenerator.GenerateModel<ScheduledClassesDetailsDB>(reader)); } reader.Close();
- This removes the need to set each variable within a model.
- Example of code being replaced:
connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { getScheduledClassesDbData.Add(new ScheduledClassesDetailsDB() { TripIdentifier = reader["TripIdentifier"].ToString().Trim(), Code = reader["training_code"].ToString().Trim(), StartTime = reader["training_default_starttime"].ToString().Trim(), EndTime = reader["training_default_endtime"].ToString().Trim(), StartDate = reader["training_startDate"].ToString().Trim(), EndDate = reader["training_endDate"].ToString().Trim(), Size = reader["training_classsize"].ToString().Trim(), Base = reader["training_base"].ToString().Trim(), BidPeriod = reader["bid_period"].ToString().Trim(), TrainingType = reader["training_code_subtype"].ToString().Trim(), Description = reader["training_code_name"].ToString().Trim(), Location = reader["training_classloc"].ToString().Trim(), }); } reader.Close();
- Note: This requires DB models to have string parameters only.
- Automation Logger
UI Tools
- Automation Element Manager
TODO: List functions - Automation Page Manager
TODO: List functions - Automation Core Driver
TODO: List functions - Automation SQL Tools
TODO: List functions
- Automation Element Manager
Tag Categories
- Quick Links Tags are used to organize test execution. There are shared tags included in this package that should be included in all tests.
In the Visual Studio, tests are organized in a heirarchy.
{ApplicationName}.{API}.Tests
{ApplicationName}Tests.{Production, Regession, Migration, Smoke, Functional, or BVT}
{ApplicationName}Tests
{FunctionName}
Example:
Cream.API.Tests
CreamTests.BVT
CreamBVTTests
CreamGetPing()
- Shared Tags:
public const string All_E2E = "All_E2E";
public const string All_BVT = "All_BVT";
public const string All_Smoke = "All_Smoke";
public const string All_Functional = "All_Functional";
public const string All_Production = "All_Production";
public const string All_Migration = "All_Migration";
public const string All_Regression = "All_Regression";
public const string Internal_Tools = "Internal_Tools";
- Project Specfic Example (All projects should have each of these tags for consistency):
namespace Cream.API.Framework.Helpers
{
public class CreamCategory
{
public const string Cream_API_All = "Cream_API_All";
public const string Cream_API_BVT = "Cream_API_BVT";
public const string Cream_API_Smoke = "Cream_API_Smoke";
public const string Cream_API_Functional = "Cream_API_Functional";
public const string Cream_API_Production = "Cream_API_Production";
public const string Cream_API_Migration = "Cream_API_Migration";
public const string Cream_API_Regression = "Cream_API_Regression";
public const string Cream_API_Internal = "Cream_API_Internal";
public const string Cream_API_TEST_Step_1 = "Cream_API_TEST_Step_1";
public const string Cream_API_QA_Step_2 = "Cream_API_QA_Step_2";
public const string Cream_API_PROD_Step_3 = "Cream_API_PROD_Step_3";
}
}
- Usage examples:
/// <summary>
/// BVT Test: Validate 200 status code of GetPing API call.
/// </summary>
[Category(SharedCategory.All_BVT)]
[Category(CreamCategory.Cream_API_All)]
[Category(CreamCategory.Cream_API_BVT)]
[TestCase]
[Retry(2)]
[Repeat(1)]
public void CreamGetPing()
/// <summary>
/// Smoke Test: Validate 200 status code of GetAuthorizations API call.
/// </summary>
[Category(SharedCategory.All_Smoke)]
[Category(CreamCategory.Cream_API_All)]
[Category(CreamCategory.Cream_API_Smoke)]
[TestCase]
[Retry(2)]
[Repeat(1)]
public void GetAuthorizations()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Appium.WebDriver (>= 5.0.0)
- AutoItX.Dotnet (>= 3.3.14.5)
- Castle.Core (>= 5.1.1)
- DotNetSeleniumExtras.PageObjects (>= 3.11.0)
- EntityFramework (>= 6.5.1)
- IBM.Data.DB.Provider (>= 11.5.5010.4)
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- Microsoft.NETCore.Platforms (>= 7.0.4)
- Microsoft.Web.Administration (>= 11.1.0)
- Microsoft.Win32.Registry (>= 5.0.0)
- NETStandard.Library (>= 2.0.3)
- Newtonsoft.Json (>= 13.0.3)
- NUnit (>= 4.1.0)
- NUnit3TestAdapter (>= 4.5.0)
- Oracle.ManagedDataAccess (>= 21.14.0)
- Oracle.ManagedDataAccess.EntityFramework (>= 21.9.0)
- Selenium.Support (>= 4.22.0)
- Selenium.WebDriver (>= 4.22.0)
- Selenium.WebDriver.ChromeDriver (>= 126.0.6478.12600)
- Syroot.Windows.IO.KnownFolders (>= 1.3.0)
- System.Console (>= 4.3.1)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- System.Diagnostics.EventLog (>= 7.0.0)
- System.Diagnostics.TraceSource (>= 4.3.0)
- System.Memory (>= 4.5.5)
- System.Numerics.Vectors (>= 4.5.0)
- System.Reflection.TypeExtensions (>= 4.7.0)
- System.Runtime (>= 4.3.1)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Security.AccessControl (>= 6.0.1)
- System.Security.Cryptography.Algorithms (>= 4.3.1)
- System.Security.Principal.Windows (>= 5.0.0)
- System.ServiceProcess.ServiceController (>= 7.0.1)
- System.Text.Encodings.Web (>= 8.0.0)
- System.Text.Json (>= 7.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|