public void TestMain() { ////Here we are instantiating a new object of class 'ActionKeywords' actionKeywords = new ActionKeywords(); //Declaring the path of the Excel file with the name of the Excel file String sPath = Constants.Path_TestData; //Here we are passing the Excel path and SheetName to connect with the Excel file //This method was created in the last chapter of 'Set up Data Engine' ExcelUtils.SetExcelFile(sPath); // now start our test cases execute_TestCase(); }
public bool searchByRegNo(string RegNo) { if (RegNo != null) { ActionKeywords.EnterText(regNumber, "Registration Number", RegNo); ActionKeywords.ClickElement(search, "Search"); if (!ActionKeywords.IsDisplayed(carSearched, "UserName", 2)) { return(true); } else { return(false); } } else { return(false); } }
//This method contains the code to perform some action (test step) //As it is completely different set of logic, which revolves around the action only, //It makes sense to keep it separate from the main driver script private static void execute_Actions() { // a sActionKeyword = null value signals the end of all test cases String sResult; if (sActionKeyword != null) { // the reflection class can help to invoke methods based on variable method string MethodInfo mi = actionKeywords.GetType().GetMethod(sActionKeyword); // Passing 'Page Object' name and 'Action Keyword' as Arguments to this class instance // This code will pass string array as parameters to every invoked method string[] args = { sPageObject, sData }; mi.Invoke(sActionKeyword, args); sResult = bResult ? Constants.KEYWORD_PASS : Constants.KEYWORD_FAIL; // Set PASS or FAIL to test steps result cell ExcelUtils.SetCellData(sResult, iTestStep, Constants.Col_TestStepResult, Constants.Sheet_TestSteps); if (!bResult) { ActionKeywords.closeBrowser("", ""); } } }