Exemple #1
0
 public static void ExecuteQuery(string query)
 {
     using (SqlCommand cmd = new SqlCommand(query, GetDBConnection()))
     {
         cmd.CommandTimeout = Int32.Parse(BuilderJson.ReturnParameterAppSettings("DB_CONNECTION_TIMEOUT"));
         cmd.Connection.Open();
         cmd.ExecuteNonQuery();
         cmd.Connection.Close();
     }
 }
Exemple #2
0
 public static void AddTestInfo(int methodLevel, string text)
 {
     if (BuilderJson.ReturnParameterAppSettings("GET_SCREENSHOT_FOR_EACH_STEP").ToString() == "true")
     {
         TEST.Log(Status.Pass, GeneralHelpers.GetMethodNameByLevel(methodLevel) + " || " + text, GetScreenShotMedia());
     }
     else
     {
         TEST.Log(Status.Pass, GeneralHelpers.GetMethodNameByLevel(methodLevel) + " || " + text);
     }
 }
Exemple #3
0
        private static SqlConnection GetDBConnection()
        {
            string connectionString = "Data Source=" + BuilderJson.ReturnParameterAppSettings("DB_URL") + "," + BuilderJson.ReturnParameterAppSettings("DB_PORT") + ";" +
                                      "Initial Catalog=" + BuilderJson.ReturnParameterAppSettings("DB_NAME") + ";" +
                                      "User ID=" + BuilderJson.ReturnParameterAppSettings("DB_USER") + "; " +
                                      "Password="******"DB_PASSWORD") + ";";

            SqlConnection connection = new SqlConnection(connectionString);

            return(connection);
        }
Exemple #4
0
        public static List <string> RetornaDadosQuery(string query)
        {
            DataSet       ds    = new DataSet();
            List <string> lista = new List <string>();

            using (SqlCommand cmd = new SqlCommand(query, GetDBConnection()))
            {
                cmd.CommandTimeout = Int32.Parse(BuilderJson.ReturnParameterAppSettings("DB_CONNECTION_TIMEOUT"));
                cmd.Connection.Open();

                DataTable table = new DataTable();
                table.Load(cmd.ExecuteReader());
                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);
        }
Exemple #5
0
        public static void CreateInstance()
        {
            string browser   = BuilderJson.ReturnParameterAppSettings("BROWSER");
            string execution = BuilderJson.ReturnParameterAppSettings("EXECUTION");
            bool   headless  = bool.Parse(BuilderJson.ReturnParameterAppSettings("HEADLESS"));

            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");
                }
            }
        }