Ejemplo n.º 1
0
        public static void Report(List <Result> stestresult, IWebDriver sdriver, string actualValue, string expectedValue)
        {
            try
            {
                if (actualValue.Equals(expectedValue))
                {
                    Result r = new Result("<font color = 'green'><strong>Pass</strong> </font>", "Actual value '" + actualValue + "' matches expected value", "");
                    stestresult.Add(r);

                    //---------------EXTENT REPORT GENERAL STEP LOG PASS------------------------------------------------------------
                    test.Log(LogStatus.Pass, "  " + actualValue, "<font color = 'green'><strong>Pass</strong> </font>");
                    //---------------------------------------------------------------------------------------------------------
                }
                else
                {
                    string       ScreenshotPaths = "";
                    ReportCustom Eresult         = new ReportCustom();
                    ScreenshotPaths = GetScreenshot(sdriver);
                    Console.WriteLine("ScreenshotPaths value");
                    Console.WriteLine(ScreenshotPaths);
                    Result r = new Result("<font color = 'red'><strong>Fail<strong></font>", "Expected value and  Actual value are not Matching--" + actualValue + "--" + expectedValue, "ScreenShot path-" + ScreenshotPaths);
                    stestresult.Add(r);

                    //---------------EXTENT REPORT GENERAL STEP LOG FAIL------------------------------------------------------------
                    if (actualValue.Contains("Exception"))
                    {
                        test.Log(LogStatus.Warning, " " + actualValue, "<font color = 'orange'><strong>Exception<strong></font>");
                        string ExtentScreenShotPath = ReportCustom.Capture(sdriver);
                        test.Log(LogStatus.Warning, "Snapshot below: " + test.AddScreenCapture(ExtentScreenShotPath), "<font color = 'orange'><strong>Exception<strong></font>");
                    }
                    else
                    {
                        test.Log(LogStatus.Fail, "Mismatch in Actual & Expected: " + actualValue + expectedValue, "<font color = 'red'><strong>Fail<strong></font>");
                        string ExtentScreenShotPath = ReportCustom.Capture(sdriver);
                        test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(ExtentScreenShotPath), "<font color = 'red'><strong>Fail<strong></font>");
                    }

                    //--------------------------------------------------------------------------------------------------------------
                }
            }
            catch
            {
                Console.WriteLine("Log message failed for " + actualValue);
                Result r = new Result("<font color = 'red'><strong> Fail <strong></font>", "Actual value '" + actualValue + "' does not match expected value '" + expectedValue + "'", "screenshot not available");
                stestresult.Add(r);
            }
        }
        public Boolean TC01_BOSearch_FF()
        {
            bool finalResult = false;

            Initial_Setup("TC01_BOSearch_FF");
            VersionConrol._initTestData(TestContext.CurrentContext.Test.MethodName);
            VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.StartTime.ToString(), VersionConrol.getTimeStamp());
            VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.ApplictionName.ToString(), "BOSearch");
            try
            {
                System.Environment.SetEnvironmentVariable("TestObjective", "Test cases to check on environment testrunup.");

                //--------------------------------TEST DATA GENERATOR-------------------------------------------------------------------------------------------

                // TestDataGenerator testgen = new TestDataGenerator(BrowserName, Driver, logStack, iExcel.ReadData(irownumber, "ProductificationBuildStatus"), iExcel.ReadData(irownumber, "Season"), iExcel.ReadData(irownumber, "SeasoninYYYYMM"), iExcel.ReadData(irownumber, "PlanMarketcode"));

                //---------------------------------------------------------------------------------------------------------

                POM_BOSearchPage Hbosearchpage = new POM_BOSearchPage(BrowserName, Driver, logStack);
                // VersionConrol._initTestData(TestContext.CurrentContext.Test.Name);
                VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.Version.ToString(), Hbosearchpage.versionInfo.GetAttribute("textContent"));
                VersionConrol.addApplication("BOSearch", Hbosearchpage.versionInfo.GetAttribute("textContent"));
                Hbosearchpage.selectDept(iExcel.ReadData(irownumber, "Department"));
                //  string str = Hbosearchpage.versionInfo.Text;
                //string sdfghjk = Hbosearchpage.versionInfo.GetAttribute("textContent");


                Hbosearchpage.clickSearch();
                Hbosearchpage.getArticleDetails();
                Hbosearchpage.productClick();


                //------------------------------ REPORTING-----------------------------------------------------------
                System.Environment.SetEnvironmentVariable("Endtime", DateTime.Now.ToString("yyyy:MM:dd_HH:mm:ss"));
                VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.EndTime.ToString(), VersionConrol.getTimeStamp());
                TestBase.sTestName = stestcaseid;
                ReportCustom swriteresult = new ReportCustom();
                swriteresult.WriteResults(stestcaseid, logStack);
                TestBase.sbrowsertype    = System.Environment.GetEnvironmentVariable("Browser1");
                TestBase.DriverCleardown = Driver;

                //----------------------VIDEO RECORDING END--------------------------------
                //stopVideoRecording();
                //-------------------------------------------------------------------------
                finalResult = true;
                VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.TestResult.ToString(), "Pass");
                return(finalResult);
            }

            catch (Exception e)
            {
                System.Environment.SetEnvironmentVariable("Endtime", DateTime.Now.ToString("yyyy:MM:dd_HH:mm:ss"));
                VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.EndTime.ToString(), VersionConrol.getTimeStamp());
                TestBase.sbrowsertype = System.Environment.GetEnvironmentVariable("Browser2");
                TestBase.sTestName    = stestcaseid;
                ReportCustom swriteresult = new ReportCustom();
                swriteresult.WriteResults(stestcaseid, logStack, finalResult);
                Console.WriteLine("StackTrace from Test Class :" + e.StackTrace);
                Console.WriteLine("Message from Test Class" + e.Message);
                //stopVideoRecording();
                TestBase.DriverCleardown = Driver;
                VersionConrol.addSubKey(TestContext.CurrentContext.Test.MethodName, subKeys.keySet.TestResult.ToString(), "Fail");
                return(finalResult);
            }
        }