コード例 #1
0
ファイル: Form1.cs プロジェクト: IAGDQA/WA
        long Form1_Load(string sPrimaryProject, string sPrimaryIP, string sSecondaryProject, string sSecondaryIP, string sTestLogFolder, string sBrowser, string sUserEmail, string sLanguage)
        {
            bPartResult = true;
            baseUrl     = "http://" + sPrimaryIP;
            if (bPartResult == true)
            {
                EventLog.AddLog("Open browser for selenium driver use");
                sw.Reset(); sw.Start();
                try
                {
                    if (sBrowser == "Internet Explorer")
                    {
                        EventLog.AddLog("Browser= Internet Explorer");
                        InternetExplorerOptions options = new InternetExplorerOptions();
                        options.IgnoreZoomLevel = true;
                        driver = new InternetExplorerDriver(options);
                        driver.Manage().Window.Maximize();
                    }
                    else
                    {
                        EventLog.AddLog("Not support temporary");
                        bPartResult = false;
                    }
                }
                catch (Exception ex)
                {
                    EventLog.AddLog(@"Error opening browser: " + ex.ToString());
                    bPartResult = false;
                }
                sw.Stop();
                PrintStep("Open browser", "Open browser for selenium driver use", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString());
            }

            //Login test
            if (bPartResult == true)
            {
                EventLog.AddLog("Login WebAccess homepage");
                sw.Reset(); sw.Start();
                try
                {
                    driver.Navigate().GoToUrl(baseUrl + "/broadWeb/bwRoot.asp?username=admin");
                    driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwconfig.asp?username=admin')]")).Click();
                    driver.FindElement(By.Id("userField")).Submit();
                    Thread.Sleep(3000);
                    driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sPrimaryProject + "')]")).Click();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog(@"Error occurred logging on: " + ex.ToString());
                    bPartResult = false;
                }
                sw.Stop();
                PrintStep("Login", "Login project manager page", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString());

                Thread.Sleep(1000);
            }

            // start to Recipe test
            if (bPartResult == true)
            {
                EventLog.AddLog("Recipe test");
                sw.Reset(); sw.Start();
                try
                {
                    EventLog.AddLog("Start Recipe Data");
                    StartViewRecipeData(sLanguage);

                    System.Threading.Thread.Sleep(5000);

                    string user = "******";
                    string pwd  = "";
                    //bool bGetTagInfoResult=true ;
                    if (null == waWebSvc)
                    {
                        waWebSvc = new WAWebService();
                    }

                    bool bInitWebSvc = waWebSvc.Init(sPrimaryIP, sPrimaryProject, user, pwd);

                    if (!bInitWebSvc)
                    {
                        EventLog.AddLog("waWebSvc.Init() Fail!!");
                        EventLog.AddLog("Error message: " + waWebSvc.GetErrMsg());
                        bPartResult = false;
                    }
                    else
                    {
                        EventLog.AddLog("waWebSvc.Init() Success");
                        EventLog.AddLog("Get Recipe tag info start!!");

                        string[] sAITagList = new string[] { "ConAna_0249", "ConAna_0250" };
                        recipe_Value = waWebSvc.GetValueText(sAITagList, false);
                        for (int i = 0; i < sAITagList.Length; i++)
                        {
                            EventLog.AddLog(string.Format("The tagname value({0}={1}) )", sAITagList[i], recipe_Value.Values[i].Value));
                            if (recipe_Value.Values[i].Value != "500")
                            {
                                bPartResult = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    EventLog.AddLog(@"Error occurred Recipe test: " + ex.ToString());
                    bPartResult = false;
                }
                sw.Stop();
                PrintStep("Verify", "Recipe test", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString());

                Thread.Sleep(1000);
            }
            //EventLog.AddLog("Start wait 10s...");
            //System.Threading.Thread.Sleep(10000);   // wait 10s for data output
            //EventLog.PrintScreen("RecipeData");

            driver.Dispose();

            #region Result judgement
            if (bFinalResult && bPartResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }
            #endregion
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: IAGDQA/WA
        long Form1_Load(string sPrimaryProject, string sPrimaryIP, string sSecondaryProject, string sSecondaryIP, string sTestLogFolder, string sBrowser, string sUserEmail, string sLanguage)
        {
            bPartResult = true;
            /*Check data transfer tag value*/
            if (bPartResult == true)
            {
                EventLog.AddLog("Check data transfer tag value");
                sw.Reset(); sw.Start();
                try
                {
                    string user = "******";
                    string pwd  = "";
                    //bool bGetTagInfoResult = true;
                    if (null == waWebSvc)
                    {
                        waWebSvc = new WAWebService();
                    }

                    bool bInitWebSvc = waWebSvc.Init(sPrimaryIP, sPrimaryProject, user, pwd);

                    if (!bInitWebSvc)
                    {
                        EventLog.AddLog("waWebSvc.Init() Fail!!");
                        EventLog.AddLog("Error message: " + waWebSvc.GetErrMsg());
                        //bGetTagInfoResult = false;
                    }
                    else
                    {
                        EventLog.AddLog("waWebSvc.Init() Success");
                        EventLog.AddLog("Get Recipe tag info start!!");

                        string[] sAITagList = new string[] { "SystemSec_0100", "zDataTransferTag" };
                        recipe_Value = waWebSvc.GetValueText(sAITagList, false);
                        //for (int i = 0; i < sAITagList.Length; i++)
                        //{
                        //    EventLog.AddLog(string.Format("The tagname value({0}={1}) )", sAITagList[i], recipe_Value.Values[i].Value));
                        //}
                        int tag1, tag2;
                        if (Int32.TryParse(recipe_Value.Values[0].Value, out tag1) && Int32.TryParse(recipe_Value.Values[1].Value, out tag2))
                        {
                            EventLog.AddLog(string.Format("The tagname value({0}={1})", sAITagList[0], recipe_Value.Values[0].Value));
                            EventLog.AddLog(string.Format("The tagname value({0}={1})", sAITagList[1], recipe_Value.Values[1].Value));
                            if (Math.Abs(tag1 - tag2) > 1 && Math.Abs(tag1 - tag2) != 59)
                            {
                                bPartResult = false;
                                EventLog.AddLog("Check value fail, The difference between the two values should be less than 1");
                            }
                            else if (tag1 < 0 || tag2 < 0)
                            {
                                bPartResult = false;
                                EventLog.AddLog("Check value fail, The value should not be negative");
                            }
                        }
                        else
                        {
                            EventLog.AddLog("String could not be parsed.");
                            EventLog.AddLog(string.Format("The tagname value({0}={1})", sAITagList[0], recipe_Value.Values[0].Value));
                            EventLog.AddLog(string.Format("The tagname value({0}={1})", sAITagList[0], recipe_Value.Values[0].Value));
                            bPartResult = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    EventLog.AddLog(@"Error occurred Check data transfer tag value: " + ex.ToString());
                    bPartResult = false;
                }
                sw.Stop();
                PrintStep("Verify", "Check data transfer tag value", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString());

                Thread.Sleep(1000);
            }
            PrintStep("CheckDataTransferFunction", "Check data transfer tag value", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString());
            /*Check data transfer tag value*/

            //driver.Dispose();

            #region Result judgement
            if (bFinalResult && bPartResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }
            #endregion
        }