I'm running Selenium tests in C# and I'm looking for a way to externalize the list of tests to a text file so they can be easily edited without need to touch the code. The problem is how to then call each line of the text file as a method? Actions seem to be the best solution but I'm having trouble converting my text string to an Action. I'm open to all suggestions on how best to do this. Thanks, J.
Note: Even though using reflection and invoke was the solutions, it doesn't work when I have methods with different number of parameters.
using McAfeeQA.Core.Log;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Interactions;
using System;
namespace SeleniumProject
{
class Program
{
static void Main(string[] args)
{
try
{
// Read through all tests and run one after another
// Global.Tests is a list of strings that contains all the tests
foreach (string testcase in Global.tests)
{
// How to run each of the below commented methods in a foreach loop???
}
//Tests.CreateNewAdminUser("admin123", "password", "admin");
//Navigation.Login(Global.language, Global.username, Global.password);
//Tests.testPermissionSets();
//Navigation.Logoff();
}
catch (Exception ex)
{
Console.WriteLine("Program exception: " + ex.ToString());
}
}
}
}