public List <string> RetornaListaDadosQuery(String query) { DataSet ds = new DataSet(); List <string> lista = new List <string>(); conn = GetDBConnection(); MySqlCommand cmd = new MySqlCommand(query, conn); cmd.CommandTimeout = Int32.Parse(JsonBuilder.ReturnParameterAppSettings("DB_CONNECTION_TIMEOUT")); cmd.Connection.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); DataTable table = new DataTable(); table.Load(rdr); ds.Tables.Add(table); cmd.Connection.Close(); if (ds.Tables[0].Columns.Count == 0) { return(null); } try { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { lista.Add(ds.Tables[0].Rows[i][j].ToString()); } } } catch (Exception) { return(null); } return(lista); }
public static void CreateInstance() { string browser = JsonBuilder.ReturnParameterAppSettings("BROWSER"); string execution = JsonBuilder.ReturnParameterAppSettings("EXECUTION"); bool headless = false; if (INSTANCE == null) { switch (browser) { case "chrome": if (execution.Equals("local")) { INSTANCE = headless ? Browsers.GetLocalChromeHeadless() : Browsers.GetLocalChrome(); } if (execution.Equals("remota")) { INSTANCE = headless ? Browsers.GetRemoteChromeHeadless() : Browsers.GetRemoteChrome(); } break; case "ie": if (execution.Equals("local")) { INSTANCE = Browsers.GetLocalInternetExplorer(); } if (execution.Equals("remota")) { INSTANCE = Browsers.GetRemoteInternetExplorer(); } break; case "firefox": if (execution.Equals("local")) { INSTANCE = Browsers.GetLocalFirefox(); } if (execution.Equals("remota")) { INSTANCE = Browsers.GetRemoteFirefox(); } break; case "edge": if (execution.Equals("local")) { INSTANCE = Browsers.GetLocalEdge(); } if (execution.Equals("remota")) { INSTANCE = Browsers.GetRemoteEdge(); } break; default: throw new Exception("O browser informado não existe ou não é suportado pela automação"); } } }
public static void CreateStep() { var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); if (ScenarioContext.Current.TestError == null) { if (JsonBuilder.ReturnParameterAppSettings("GET_SCREENSHOT_FOR_EACH_STEP").Equals("true")) { switch (stepType) { case "Given": scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); break; case "When": scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); break; case "Then": scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); break; case "And": scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); break; } } else { switch (stepType) { case "Given": scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); break; case "When": scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); break; case "Then": scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); break; case "And": scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); break; } } } if (ScenarioContext.Current.TestError != null) { switch (stepType) { case "Given": if (ScenarioContext.Current.TestError.InnerException == null) { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioStepContext.Current.StepInfo.Text).Error("<pre>" + "Exception: " + ScenarioContext.Current.TestError.InnerException + "</pre>" + "<pre>" + "Stack Trace: " + ScenarioContext.Current.TestError.StackTrace + "</pre>").AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); } break; case "When": if (ScenarioContext.Current.TestError.InnerException == null) { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Error(ScenarioStepContext.Current.StepInfo.Text).Error("<pre>" + "Exception: " + ScenarioContext.Current.TestError.InnerException + "</pre>" + "<pre>" + "Stack Trace: " + ScenarioContext.Current.TestError.StackTrace + "</pre>").AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); } break; case "Then": if (ScenarioContext.Current.TestError.InnerException == null) { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message); } else { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Error(ScenarioStepContext.Current.StepInfo.Text).Error("<pre>" + "Exception: " + ScenarioContext.Current.TestError.InnerException + "</pre>" + "<pre>" + "Stack Trace: " + ScenarioContext.Current.TestError.StackTrace + "</pre>").AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); } break; case "And": if (ScenarioContext.Current.TestError.InnerException == null) { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text).Fail("<pre>" + ScenarioContext.Current.TestError.Message + "</pre>"); } else { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text).Error(ScenarioStepContext.Current.StepInfo.Text).Error("<pre>" + "Exception: " + ScenarioContext.Current.TestError.InnerException + "</pre>" + "<pre>" + "Stack Trace: " + ScenarioContext.Current.TestError.StackTrace + "</pre>").AddScreenCaptureFromPath(GeneralHelpers.GetScreenshot(reportPath)); } break; } } }