public void ConsoleOutputsReadExecutionTest() { //Arrange TestNGExecuterService service = new TestNGExecuterService(); GingerAction GA = new GingerAction(); List <TestNGTestParameter> paramsToOveride = new List <TestNGTestParameter>(); paramsToOveride.Add(new TestNGTestParameter() { Name = "Num1", Value = "7" }); paramsToOveride.Add(new TestNGTestParameter() { Name = "Num2", Value = "3" }); //Act service.ExecuteTestNGXML(GA, OverwriteJavaHomePath: null, JavaProjectBinPath: Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "bin"), JavaProjectResourcesPath: Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "Resources"), TestngXmlPath: Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "bin", "Calculator", "testng.xml"), TestngXmlParametersToOverwrite: paramsToOveride, OverwriteOriginalTestngXml: false, ParseConsoleOutputs: true, FailActionDueToConsoleErrors: true, ParseTestngResultsXml: true, OverwriteTestngResultsXmlDefaultFolderPath: null, FailActionDueToTestngResultsXmlFailures: true); //Assert Assert.AreEqual((GA.Errors == null || GA.Errors.Count() == 0), true, "No Execution Errors validation"); Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); Assert.AreEqual(General.OutputParamExist(GA, "Multipliy Result", "21"), true, "Console Multipliy Output captured validation"); Assert.AreEqual(General.OutputParamExist(GA, "Sum Result", "10"), true, "Console Sum Output captured validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Passed Test Methods", "2"), true, "TestNg Report XML Statistics Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, "CalculatorTests- Suite Start Time"), true, "TestNg Report XML Suite details Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testMoltiple-Test Status", "PASS"), true, "TestNg Report XML Test 1 Status Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testSum-Test Status", "PASS"), true, "TestNg Report XML Test 2 Status Parsing validation"); }
public void RunGroovyScriptOnLinux() { //Arrange GroovyScriptExecuterService groovyScriptExecuterService = new GroovyScriptExecuterService(); GingerAction GA = new GingerAction(); List <GroovyPrameters> groovyPrameters = new List <GroovyPrameters>(); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 1", Value = "10" }); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 2", Value = "20" }); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 4", Value = "30" }); //Act groovyScriptExecuterService.ExecuteGroovyScriptFile(GA, "", @"/home/ginger/ginger_tests/Groovy_Plugin_Test/BasicScript.groovy", groovyPrameters); //Assert string str = string.Empty; Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); foreach (IGingerActionOutputValue s in GA.Output.OutputValues) { str = s.Value.ToString(); } Assert.AreEqual("30", str); }
private IWebElement LocateElement(GingerAction gingerAction, eElementType elementType, eLocateBy locateBy, string locateValue) { try { IWebElement e = null; switch (locateBy) { case eLocateBy.Id: e = mDriver.FindElement(By.Id(locateValue)); return(e); case eLocateBy.Name: e = mDriver.FindElement(By.Name(locateValue)); return(e); case eLocateBy.Text: e = mDriver.FindElement(By.CssSelector("text=" + locateValue)); return(e); case eLocateBy.XPath: e = mDriver.FindElement(By.XPath(locateValue)); return(e); //TODO: all the rest default: gingerAction.AddError("LocateElement", "Locator not implemented - " + locateBy); return(null); } } catch (Exception ex) { gingerAction.AddError("LocateElement", ex.Message); return(null); } }
public void RunScript6() { // Arrange GingerPythonService service = new GingerPythonService(); GingerAction GA = new GingerAction(); String script6 = @"import sys a = sys.argv[1] b = sys.argv[2] print('a=' + a) print('b=' + b) sum = int(a) + int(b) print('sum=' + str(sum))"; //Act List <Arg> args = new List <Arg>(); args.Add(new Arg("Param 1", "4")); args.Add(new Arg("Param 2", "7")); service.RunScript(GA, script6, args); //Assert Assert.AreEqual("4", GA.Output["a"]); Assert.AreEqual("7", GA.Output["b"]); Assert.AreEqual("11", GA.Output["sum"]); }
public Stop(GingerAction act) { InitializeComponent(); mAct = act; //ActionParam AP1 = mAct.GetOrCreateParam("ProviderID"); //ProviderID.BindControl(AP1); }
// Special MySQL actions public void Ping(GingerAction GingerAction, string aa) // !!!!!!!! aa { MySqlConnection MySqlConnection = new MySqlConnection(); bool b = MySqlConnection.Ping(); GingerAction.AddOutput("Ping", b); }
public void SimpleScriptFileTestOnLinux() { //Arrange RubyScriptExecuterService rubyScriptExecuterService = new RubyScriptExecuterService(); GingerAction GA = new GingerAction(); List <RubyPrameters> rubyPrameters = new List <RubyPrameters>(); rubyPrameters.Add(new RubyPrameters() { Param = "Param 1", Value = "10" }); rubyPrameters.Add(new RubyPrameters() { Param = "Param 2", Value = "20" }); //Act rubyScriptExecuterService.ExecuteRubyScriptFile(GA, TestResources.GetTestResourcesFile("test.rb"), "=", rubyPrameters); //Assert string str = string.Empty; Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); foreach (IGingerActionOutputValue s in GA.Output.OutputValues) { str = s.Value.ToString(); } Assert.AreEqual(str.Contains("30"), true); }
public void SimpleScriptContentTest() { //Arrange RubyScriptExecuterService rubyScriptExecuterService = new RubyScriptExecuterService(); GingerAction GA = new GingerAction(); List <RubyPrameters> rubyPrameters = new List <RubyPrameters>(); rubyPrameters.Add(new RubyPrameters() { Param = "Param 1", Value = "10" }); rubyPrameters.Add(new RubyPrameters() { Param = "Param 2", Value = "20" }); string script = @"sum=ARGV[0].to_i+ARGV[1].to_i puts ""Result : #{sum}"""; //Act rubyScriptExecuterService.ExecuteRubyScript(GA, script, ":", rubyPrameters); //Assert string str = string.Empty; foreach (IGingerActionOutputValue s in GA.Output.OutputValues) { str = s.Value.ToString(); } Assert.AreEqual(str.Contains("30"), true); }
public void GotoHTMLControls() { string HTMLControlFile = "file://" + TestResources.GetTestResourcesFile("HTMLControls.html"); GingerAction GA1 = new GingerAction(); mSeleniumDriver.Navigate(GA1, HTMLControlFile); }
public void HTTP(GingerAction gingerAction, string url) { if (mDisplay != null) { mDisplay.URL = url; } // mDisplay.WriteLine("Geeting HTTP URL" + url); // example to show error checks if (!url.StartsWith("HTTP", StringComparison.InvariantCultureIgnoreCase)) { gingerAction.AddError("WebServicesDriver.HTTP", "URL must start with HTTP - " + url); return; } using (var client = new HttpClient()) { Stopwatch stopwatch = Stopwatch.StartNew(); var result = client.GetAsync(url).Result; stopwatch.Stop(); gingerAction.Output.Add("Status Code", result.StatusCode.ToString()); gingerAction.Output.Add("Elapsed", stopwatch.ElapsedMilliseconds.ToString()); if (mDisplay != null) { mDisplay.AddLog("Elapsed - " + stopwatch.ElapsedMilliseconds); } } gingerAction.ExInfo = "URL: " + url; }
public void SimpleJavaFreeCommandExecutionTest() { //Arrange TestNGExecuterService service = new TestNGExecuterService(); GingerAction GA = new GingerAction(); bool parseReport = false; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { parseReport = true; } //Act service.ExecuteJavaFreeCommand(GA, OverwriteJavaHomePath: null, JavaWorkingFolderPath: TestResources.GetTestResourcesFolder(@"JavaTestNG"), FreeCommandArguments: string.Format("java -cp \"{0}{1}{2}\" org.testng.TestNG \"{3}\"", Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "bin"), General.GetOSFoldersSeperator(), Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "Resources", "*"), Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "src", "Calculator", "testng.xml")), TestngXmlPath: null, TestngXmlParametersToOverwrite: null, OverwriteOriginalTestngXml: false, ParseConsoleOutputs: false, FailActionDueToConsoleErrors: false, ParseTestngResultsXml: parseReport, OverwriteTestngResultsXmlDefaultFolderPath: Path.Combine(TestResources.GetTestResourcesFolder("JavaTestNG"), "test-output"), FailActionDueToTestngResultsXmlFailures: true); //Assert Assert.AreEqual((GA.Errors == null || GA.Errors.Count() == 0), true, "No Execution Errors validation"); if (parseReport) { Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); Assert.AreEqual(General.OutputParamExist(GA, "CalculatorTests- Suite Start Time"), true, "TestNg Report XML Suite details Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testMoltiple-Test Status", "PASS"), true, "TestNg Report XML Test 1 Status Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testSum-Test Status", "PASS"), true, "TestNg Report XML Test 2 Status Parsing validation"); } }
public void MavenFreeCommandXmlParametersOverrideOnOriginalXmlExecutionTest() { //Arrange TestNGExecuterService service = new TestNGExecuterService(); GingerAction GA = new GingerAction(); List <TestNGTestParameter> paramsToOveride = new List <TestNGTestParameter>(); paramsToOveride.Add(new TestNGTestParameter() { Name = "Num1", Value = "6" }); paramsToOveride.Add(new TestNGTestParameter() { Name = "Num2", Value = "7" }); //Act service.ExecuteMavenFreeCommand(GA, OverwriteMavenHomePath: null, MavenProjectFolderPath: TestResources.GetTestResourcesFolder(@"MavenTestNG"), FreeCommandArguments: "clean install test -DsuiteXmlFile=\"src/main/java/com/Calculator/testng.xml\"", TestngXmlPath: Path.Combine(TestResources.GetTestResourcesFolder("MavenTestNG"), "src", "main", "java", "com", "Calculator", "testng.xml"), TestngXmlParametersToOverwrite: paramsToOveride, OverwriteOriginalTestngXml: true, ParseConsoleOutputs: true, FailActionDueToConsoleErrors: false, ParseTestngResultsXml: true, OverwriteTestngResultsXmlDefaultFolderPath: null, FailActionDueToTestngResultsXmlFailures: true); //Assert Assert.AreEqual((GA.Errors == null || GA.Errors.Count() == 0), true, "No Execution Errors validation"); Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); Assert.AreEqual(General.OutputParamExist(GA, "Multipliy Result", "42"), true, "Console Multipliy Output captured validation"); Assert.AreEqual(General.OutputParamExist(GA, "Sum Result", "13"), true, "Console Sum Output captured validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Passed Test Methods", "2"), true, "TestNg Report XML Statistics Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, "CalculatorTests- Suite Start Time"), true, "TestNg Report XML Suite details Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testMoltiple-Test Status", "PASS"), true, "TestNg Report XML Test 1 Status Parsing validation"); Assert.AreEqual(General.OutputParamExist(GA, @"test1\testSum-Test Status", "PASS"), true, "TestNg Report XML Test 2 Status Parsing validation"); }
public void TestNGExecutionResultsParsingValidation() { //Arrange GingerAction GA = new GingerAction(); string resultsXmlPath = TestResources.GetTestResourcesFile("testng-results.xml"); //Act TestNGReportXML ngReport = new TestNGReportXML(resultsXmlPath); ngReport.ParseTestNGReport(GA, true); //Assert Assert.AreEqual(string.IsNullOrEmpty(ngReport.LoadError), true, "No report parsing errors validation"); Assert.AreEqual(GA.Errors, @"The Test method 'Dynamic Accessory from Search\getAllCategories' failed with the error: 'Connection reset'", "Error been added correctly to Ginger Action validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Test Methods", "101"), true, "Output Value- '' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Passed Test Methods", "3"), true, "Output Value- 'Total Passed Test Methods' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Failed Test Methods", "1"), true, "Output Value- 'Total Failed Test Methods' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Skipped Test Methods", "14"), true, "Output Value- 'Total Skipped Test Methods' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Total Ignored Test Methods", "83"), true, "Output Value- 'Total Ignored Test Methods' validation"); Assert.AreEqual(GA.Output.OutputValues.Where(x => x.Param == "Dynamic Accessory from Search- Suite Start Time").First().Value.ToString().Contains("19"), true, string.Format("Output Value- 'Dynamic Accessory from Search- Suite Start Time' validation, value:'{0}'", GA.Output.OutputValues.Where(x => x.Param == "Dynamic Accessory from Search- Suite Start Time").First().Value)); Assert.AreEqual(GA.Output.OutputValues.Where(x => x.Param == "Dynamic Accessory from Search- Suite Finish Time").First().Value.ToString().Contains("40"), true, "Output Value- 'Dynamic Accessory from Search- Suite Finish Time' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Dynamic Accessory from Search- Suite Duration (MS)", "21069"), true, "Output Value- 'Dynamic Accessory from Search- Suite Duration (MS)' validation"); Assert.AreEqual(General.OutputParamExist(GA, "Automation_Setup\\initialAutomationSetup-Test Status", "PASS"), true, "Output Value- PASS test validation"); Assert.AreEqual(General.OutputParamExist(GA, "Dynamic Accessory from Search\\selectProductOfferingDynamic-Test Status", "SKIP"), true, "Output Value- SKIP test validation"); Assert.AreEqual(General.OutputParamExist(GA, "Dynamic Accessory from Search\\selectProductOfferingDynamic-Error Message", "Attribute: categoryIds is not exist in context."), true, "Output Value- Skipped test Error Message validation"); Assert.AreEqual(General.OutputParamExist(GA, "Dynamic Accessory from Search\\getAllCategories-Test Status", "FAIL"), true, "Output Value- FAIL test validation"); Assert.AreEqual(General.OutputParamExist(GA, "Dynamic Accessory from Search\\getAllCategories-Error Message", "Connection reset"), true, "Output Value- Failed test Error Message validation"); }
public void ScriptTestBinFolder() { //Arrange GroovyScriptExecuterService groovyScriptExecuterService = new GroovyScriptExecuterService(); GingerAction GA = new GingerAction(); List <GroovyPrameters> groovyPrameters = new List <GroovyPrameters>(); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 1", Value = "10" }); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 2", Value = "20" }); groovyPrameters.Add(new GroovyPrameters() { Param = "Param 4", Value = "30" }); //Act groovyScriptExecuterService.ExecuteGroovyScriptFile(GA, @"C:\Work\Groovy\Groovy bin folder\groovy 2.5.6\bin", @"C:\\Work\Groovy\\BasicScript.groovy", groovyPrameters); //Assert string str = string.Empty; Assert.AreEqual((GA.Output != null && GA.Output.OutputValues.Count > 0), true, "Execution Output values found validation"); foreach (IGingerActionOutputValue s in GA.Output.OutputValues) { str = s.Value.ToString(); } Assert.AreEqual("30", str); }
public void GingerOfficePluginTestActionx3() { //Arrange ObservableList <PluginPackage> Plugins = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>(); PluginPackage p = (from x in Plugins where x.PluginID == "GingerOfficePlugin" select x).SingleOrDefault(); ObservableList <StandAloneAction> list = p.GetStandAloneActions(); StandAloneAction standAloneAction = list[0]; GingerAction GA = new GingerAction(standAloneAction.ID); GA.InputParams["PluginID"].Value = p.PluginID; GA.InputParams["PluginActionID"].Value = standAloneAction.ID; GA.InputParams["A"].Value = "hi"; GA.InputParams["B"].Value = "yo"; // Act for (int i = 0; i < 3; i++) { WorkSpace.Instance.PlugInsManager.Execute(GA); } //Assert Assert.AreEqual(1, WorkSpace.Instance.LocalGingerGrid.NodeList.Count, "GingerGrid nodes 1 - only one service is up - reuse"); }
public void TakeScreenShot(GingerAction gingerAction, eScreens screens = eScreens.Active) { //TODO: handle screen - take all etc.. Screenshot SS = ((ITakesScreenshot)mDriver).GetScreenshot(); byte[] b = SS.AsByteArray; gingerAction.Output.Add("SC1", b); }
public LoadInteractionsFile(GingerAction act) { InitializeComponent(); mAct = act; //ActionParam AP1 = mAct.GetOrCreateParam("FileName"); //FileName.BindControl(AP1); }
public void Time(GingerAction act) { Console.WriteLine("Echo"); act.Output.Values.Add(new ActionOutputValue() { Param = "CurrentTime", ValueString = DateTime.Now.ToString() }); act.ExInfo = "Echo Result"; }
private void UpdateActionParamTypes(GingerAction gA, MethodInfo methodInfo) { foreach (ParameterInfo PI in methodInfo.GetParameters()) { if (PI.ParameterType != typeof(GingerAction)) { ActionParam AP = gA.InputParams.GetOrCreateParam(PI.Name); AP.ParamType = PI.ParameterType; } } }
public void ReadExcelRow3GetColumnsCount() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.ReadExcelRow(GA, EXCEL_FILE_NAME, "Sheet1", "#3", "#1,#2,#4"); // Read row 3 columns 1,2,4 //Assert // Assert.AreEqual(3, GA.Output.Values.Count); }
public void ReadUpdateFailExcelCellWithRowNo() { ///Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.ReadExcelAndUpdate(GA, EXCEL_FILE_NAME, "Sheet1", "#5", string.Empty, "ID=5, #C='Thomas', First='Sarah'"); //Assert Assert.IsFalse(string.IsNullOrEmpty(GA.Errors)); }
public void AppendNewRowSimple() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); x.AppendData(GA, EXCEL_FILE_NAME, "Sheet1", "'55', 'John', 'Smith'"); // int index = Convert.ToInt32(GA.Output.Values[0].ValueString); //Assert // Assert.IsTrue(index > 0); }
public void AppendNewRowByColumnHeading() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); x.AppendData(GA, EXCEL_FILE_NAME, "Sheet1", "Last='aaa', Used='No'"); // int index = Convert.ToInt32(GA.Output.Values[0].ValueString); //Assert // Assert.IsTrue(index > 0); }
public void AppendNewRowByColumnName() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); x.AppendData(GA, EXCEL_FILE_NAME, "Sheet1", "#B='ColName', #E='Yes'"); // int index = Convert.ToInt32(GA.Output.Values[0].ValueString); //Assert // Assert.IsTrue(index > 0); }
public void WriteExcelPass() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.WriteExcel(GA, EXCEL_FILE_NAME, "Sheet1", 7, "B", "Write Cell"); //Assert Assert.IsTrue(string.IsNullOrEmpty(GA.Errors)); }
public void ReadExcelCellRow3ColumnB() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.ReadExcelCell(GA, EXCEL_FILE_NAME, "Sheet1", "#3", "#B"); //Assert //Assert.AreEqual("Moshe", GA.Output.Values[0].ValueString, "Row 3 Col B = Moshe"); }
public void ReadExcelCellRow3ColumnColumnCount() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.ReadExcelCell(GA, EXCEL_FILE_NAME, "Sheet1", "#3", "#B"); //Assert //Assert.AreEqual(1, GA.Output.Values.Count); }
public void FileCopy(ref GingerAction GA, string SourceFileName, string destFileName, bool overWrite = false) { if (File.Exists(SourceFileName)) { File.Copy(SourceFileName, destFileName, overWrite); } else { throw new Exception("File not found for copy: " + SourceFileName); } GA.ExInfo = "File copied: " + SourceFileName + "==>" + destFileName; }
public void FileExist(ref GingerAction GA, string FilePath) { if (File.Exists(FilePath)) { GA.Output.Add("Value", "True"); } else { GA.Output.Add("Value", "False"); } GA.ExInfo = "FileExist: " + FilePath; }
public void ReadExcelCellWhereFirstEquelMosheGetID() { //Arrange ExcelService x = new ExcelService(); GingerAction GA = new GingerAction(); //Act x.ReadExcelCell(GA, EXCEL_FILE_NAME, "Sheet1", "First='Moshe'", "ID"); //Assert // Assert.AreEqual("24", GA.Output.Values[0].ValueString, "First=Moshe ID=24"); }