示例#1
0
 /// <summary>
 /// Kill a pocess given the name of the process
 /// The process is killed if the pocess is longer than 3 seconds
 /// </summary>
 /// <param name="nameOfProcessToKill"></param>
 public static void killProcessByNames(string nameOfProcessToKill)
 {
     SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), nameOfProcessToKill);
     string[] nameOfProcessToKillList = nameOfProcessToKill.Split(',');
     foreach (string nameOfProcess in nameOfProcessToKillList)
     {
         try
         {
             foreach (Process proc in Process.GetProcessesByName(nameOfProcess))
             {
                 DateTime procStartTime = proc.StartTime;
                 DateTime dateNow       = DateTime.Now;
                 long     diff          = (long)(dateNow - procStartTime).TotalMilliseconds;
                 //Kill the process if longer than 3 secunds
                 if (diff > 3000 && !(proc.ProcessName.ToLower().Contains("excel")))
                 {
                     proc.Refresh();
                     proc.Kill();
                 }
                 if (proc.ProcessName.ToLower().Contains("excel") && diff < 3000)
                 {
                     proc.Refresh();
                     proc.Kill();
                 }
             }
         }
         catch (Exception e)
         {
             SAFEBBALog.Warning("The process, " + nameOfProcessToKill + " could not be killed. See Exception: \n" + e);
         }
         Thread.Sleep(1000);
     }
 }
        // Click the menu from the left side of the panel
        public void clickTableLink(String id, String text)
        {
            IWebElement webelement = findWebDriverElement.waitForElementById(null, null, id);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementLiList = webelement.FindElements(By.TagName("table"));

            try
            {
                foreach (IWebElement elementLi in elementLiList)
                {
                    IReadOnlyCollection <IWebElement> elementUlList = elementLi.FindElements(By.TagName("tbody"));

                    foreach (IWebElement elementUl in elementUlList)
                    {
                        if (elementUl.GetAttribute("innerHTML").Contains(text))
                        {
                            elementUl.Click();
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }

            catch (Exception e) { SAFEBBALog.TestCaseErrorMessage(e); }
        }
示例#3
0
        public void SeleniumQuit()
        {
            Console.WriteLine("Quitting Driver...........");
            try
            {
                if (driver != null)
                {
                    driver.Quit();
                    driver = null;
                }

                SAFEBBALog.Info("Closing Web Driver...........");
                ProcessMgn.killProcessByNames("IEDriverServer");    //Make sure the process is killed

                //Try to add the link to the Result file and screenshots if necessary
                this.TestContext.AddResultFile(WriteTestResultsExcel.testResultFilePath);
                if (WriteTestResultsExcel.errorTestResultFilePath != null)
                {
                    this.TestContext.AddResultFile(WriteTestResultsExcel.errorTestResultFilePath);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
示例#4
0
        public static void setTestClassStart(String testClassName, String dateTime)
        {
            try
            {
                SAFEBBALog.Info("Executing Test Cases for Class Started for Class : " + testClassName);

                errorTestResultFilePath = null;

                //For Directory
                if (!Directory.Exists(resultFolderPath))
                {
                    resultFolderPath = resultFolderPath + "_" + dateTime;
                    Directory.CreateDirectory(resultFolderPath);
                    System.IO.File.Copy(@Environment.CurrentDirectory + "\\Test_Results_Template.xlsx", resultFolderPath + "\\Test_Results" + "_" + dateTime + ".xlsx");
                }

                testResultFilePath = resultFolderPath + "\\Test_Results" + "_" + dateTime + ".xlsx";

                testResultFile = new FileInfo(testResultFilePath);

                excelPackage = new ExcelPackage(testResultFile);

                testCaseWorkSheet = excelPackage.Workbook.Worksheets.First();

                testStepWorkSheet = excelPackage.Workbook.Worksheets.Last();
            }

            catch (Exception e)
            {
                SAFEBBALog.TestCaseErrorMessage(e);
            }
        }
示例#5
0
        public static void setTestClassFinish(String testClassName)
        {
            try

            {
                SAFEBBALog.Info("Executing Test Cases Finished for Class  : " + testClassName);

                excelPackage.SaveAs(testResultFile);

                excelPackage.Dispose();

                // excelPackage.Load(holdingStream);

                SAFEBBALog.Info("Saving Test Results for Class : " + testClassName + " in path -> " + testResultFilePath);
            }
            catch (Exception e)
            {
                SAFEBBALog.TestCaseErrorMessage(e);
            }
            finally
            {
                //tc_RowIndex = 7; ts_RowIndex = 7; testCaseIDCounter = 1;
                testStepIDCounter = 1;
            }
        }
示例#6
0
        //Method Usage example as give below
        //getDictionaryValue(Login_Objects.LOGIN_APRISO_USERNAME, DOMAttributes.css_class.ToString());

        public String getDictionaryValue(Dictionary <String, String> dictionary, String Key)
        {
            try
            {
                String value = null;
                if (dictionary != null)
                {
                    if (dictionary.ContainsKey(Key))
                    {
                        value = dictionary[Key];
                        return(value);
                    }
                    else
                    {
                        return(value);
                    }
                }
                else
                {
                    return(value);
                }
            }
            catch (Exception e)
            {
                SAFEBBALog.LogStackTrace(e);
                return(null);
            }
        }
示例#7
0
 public void RunStarted(string name, int testCount)
 {
     SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName());
     failedTestCasesToReRun            += ConfigParameters.PATH_NUNIT_PACKAGE_CONSOLE_EXE;
     SAFEBBALog.TotalNumberOfTestsToRun = testCount;
     SAFEBBALog.PrintApplicationConfigurations();
 }
示例#8
0
        /**Execute the java script, scriptToExecute, on the site driver, e.g. to simulate an action that cannot be achieved by a webdriver action.
         * Such actions could be as forcing the browser to show hidden elements, get browser information, etc.
         * The java script execution should be used with caution since it not an exact simulation of the user behavior.
         * @param scriptToExecute
         * @return an object
         */
        public Object ExecuteJavaScript(string pageNameToSwitchTo, string frameNameToSwitchTo, string scriptToExecute, params IWebElement[] args)
        {
            SAFEBBALog.Debug("scriptToExecute: " + scriptToExecute);
            Object obj           = null;
            long   maxTimeToWait = CommonUtilities.GetCurrentTimeMillis() + CommonUtilities.GLOBAL_TIMEOUT_TIME_IN_MSEC;

            while (obj == null && maxTimeToWait > CommonUtilities.GetCurrentTimeMillis())
            {
                try
                {
                    //driver = FindWebDriverElement.SwitchToFrameOrWindowByName(this.driver, pageNameToSwitchTo, frameNameToSwitchTo);
                    IJavaScriptExecutor iJavaScriptExecutor = (IJavaScriptExecutor)driver;

                    {
                        if (args != null && args.Length > 0)
                        {
                            obj = (Object)iJavaScriptExecutor.ExecuteScript(scriptToExecute, args[0]);
                            SAFEBBALog.Debug("object: " + obj);
                            return(obj);
                        }
                        else
                        {
                            obj = (Object)iJavaScriptExecutor.ExecuteScript(scriptToExecute);
                            SAFEBBALog.Debug("object: " + obj);
                            return(obj);
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }
            return(obj);
        }
示例#9
0
        public static long GetCurrentTimeMillis()
        {
            SAFEBBALog.Debug(GetClassAndMethodName());
            DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            return((long)((DateTime.UtcNow - Jan1st1970).TotalMilliseconds));
        }
示例#10
0
        // Find pattern as //a[@title="SHIFT <> Å"]
        public static String XPathEquals(String element, String attribute, String value)
        {
            String xPathEquals = "//" + element + "[@" + attribute + "=\"" + value + "\"]";

            SAFEBBALog.Debug("xPathEquals: " + xPathEquals);
            return(xPathEquals);
        }
示例#11
0
 public void SuiteFinished(TestResult result)
 {
     SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName());
     if (SAFEBBALog.NumberOfExecutedTests == 0 && !isScreenShotTaken)
     {
         CreatScreenShotOnFailure(result);
     }
 }
示例#12
0
        public static string GetCurrentDate()
        {
            SAFEBBALog.Debug(GetClassAndMethodName());
            DateTime dt   = DateTime.Now;
            string   date = dt.ToString("dd_MM_yyyy_HH_mm_ss");

            return(date);
        }
示例#13
0
        /// <summary>
        /// Same as {@methodref executeJavaScript} but with a WaitForAjaxCallToFinish before executing the java script
        /// </summary>
        /// <param name="pageNameToSwitchTo"></param>
        /// <param name="frameNameToSwitchTo"></param>
        /// <param name="scriptToExecute"></param>
        /// <returns></returns>
        public Object executeJavaScriptWithWaitForAjaxCallToFinish(string pageNameToSwitchTo, string frameNameToSwitchTo, string scriptToExecute)
        {
            SAFEBBALog.Debug("scriptToExecute: " + scriptToExecute);
            WaitForAjaxCallToFinish();
            Object obj = ExecuteJavaScript(pageNameToSwitchTo, frameNameToSwitchTo, scriptToExecute);

            WaitForAjaxCallToFinish();
            return(obj);
        }
示例#14
0
        /// <summary>
        /// Return a list of web element using the javascript to find element
        /// </summary>
        /// <param name="pageNameToSwitchTo"></param>
        /// <param name="frameNameToSwitchTo"></param>
        /// <param name="scriptToExecute"></param>
        /// <returns></returns>
        public ReadOnlyCollection <IWebElement> ExecuteJavaScriptIWebElementList(string pageNameToSwitchTo, string frameNameToSwitchTo, string scriptToExecute)
        {
            SAFEBBALog.Debug("scriptToExecute: " + scriptToExecute);
            driver = FindWebDriverElement.SwitchToFrameOrWindowByName(this.driver, pageNameToSwitchTo, frameNameToSwitchTo);
            IJavaScriptExecutor iJavaScriptExecutor          = (IJavaScriptExecutor)driver;
            ReadOnlyCollection <IWebElement> iWebElementList = (ReadOnlyCollection <IWebElement>)iJavaScriptExecutor.ExecuteScript(scriptToExecute);

            SAFEBBALog.Debug("iWebElementList: " + iWebElementList);
            return(iWebElementList);
        }
示例#15
0
        public static string CreateFolder(string folderPath)
        {
            SAFEBBALog.Debug(GetClassAndMethodName());
            string fullDirectoryPath = GetProjectDirectory() + folderPath;

            if (!Directory.Exists(fullDirectoryPath))
            {
                Directory.CreateDirectory(fullDirectoryPath);
            }
            return(fullDirectoryPath);
        }
示例#16
0
        public static string GetProjectDirectory()
        {
            SAFEBBALog.Debug(GetClassAndMethodName());
            var    outPutDirectory = GetOutPutDirectory();
            int    startIndex      = outPutDirectory.IndexOf("\\") + 1;
            int    binIndex        = outPutDirectory.IndexOf("bin");
            int    length          = binIndex - startIndex;
            string projectDir      = outPutDirectory.Substring(startIndex, length);

            return(projectDir);
        }
示例#17
0
 /// <summary>
 /// Used Only wiht JQuery based web runningApplication
 /// </summary>
 public void WaitForAjaxCallToFinish()
 {
     SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName());
     try
     {
         AjaxCallToFinish();
     }
     catch
     {
         SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName(), "CALLING THE JAVA SCRIPT THE FIST TIME FAILED. TRYING THE ONE MORE TIME");
         AjaxCallToFinish();
     }
 }
示例#18
0
        /// <summary>
        /// Take a print screen and save the image as .png file.
        /// </summary>
        /// <param name="imageFullPathAndName"></param>
        public static void CreateAndSaveScreenShot(string imageFullPathAndName)
        {
            SAFEBBALog.Debug(GetClassAndMethodName());
            Screen   screen   = Screen.PrimaryScreen;
            Bitmap   bmp      = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
            Graphics graphics = Graphics.FromImage(bmp);

            graphics.CopyFromScreen(0, 0, 0, 0, new Size(screen.Bounds.Width, screen.Bounds.Height));
            bmp.Save(imageFullPathAndName, ImageFormat.Png);
            string imageFullPathAndNameWithoutC    = imageFullPathAndName.Replace("C:", "").Replace("C:", "");
            string imageFullPathAndNameIncludeFile = "file://///" + System.Environment.MachineName + imageFullPathAndNameWithoutC;

            SAFEBBALog.Info("The screenshot is saved: " + imageFullPathAndNameIncludeFile);
        }
示例#19
0
        /// <summary>
        /// Create a screen shot when a test case fail
        /// The screen shot is saved in
        /// </summary>
        /// <param name="result"></param>
        private void CreatScreenShotOnFailure(TestResult result)
        {
            SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName());
            SAFEBBALog.IsPreviousTestCaseSucceeded = true;
            string fullname = result.FullName;

            if (result.ResultState == ResultState.Error || result.ResultState == ResultState.Failure)
            {
                string testCaseName = result.Name;
                string fullNameWithoutTestCaseName = fullname.Substring(0, (fullname.Length - testCaseName.Length - 1));
                int    startIndexForTestClass      = fullNameWithoutTestCaseName.LastIndexOf(".");
                string testClassName        = fullNameWithoutTestCaseName.Substring(startIndexForTestClass + 1);
                string fullFolderPath       = CommonUtilities.CreateFolder("bin\\Debug\\ScreenShots\\" + testClassName);
                string imageFullPathAndName = fullFolderPath + "\\" + testCaseName + CommonUtilities.GetCurrentDate() + ".png";
                CommonUtilities.CreateAndSaveScreenShot(imageFullPathAndName);

                isScreenShotTaken = true;
                SAFEBBALog.IsPreviousTestCaseSucceeded = false;
                failedTestCasesToReRun += fullname + ",";
            }
        }
示例#20
0
        /// <summary>
        /// Wait for a page to loaded on the screen
        /// </summary>
        private void AjaxCallToFinish()
        {
            string documentReadyState         = "";
            string documentReadyStateStripped = "";
            long   maxTimeToWait = CommonUtilities.GetCurrentTimeMillis() + CommonUtilities.GLOBAL_TIMEOUT_TIME_IN_MSEC;

            while (!documentReadyStateStripped.Equals("complete") && maxTimeToWait > CommonUtilities.GetCurrentTimeMillis())
            {
                try
                {
                    SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName());
                    String scriptToExecute = "return document.readyState";
                    documentReadyState         = (string)driver.ExecuteScript(scriptToExecute);
                    documentReadyStateStripped = documentReadyState.Trim().ToLower();
                }
                catch
                {
                    SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), "JAVASCRIPT NOT READY YET");
                    Thread.Sleep(500);
                }
            }
        }
示例#21
0
        /// <summary>
        /// Deletes all the files within the specified folder
        /// </summary>
        /// <param name="folder">The folder from which we wish to delete all of the files</param>
        public static void ClearFolder(DirectoryInfo folder)
        {
            SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), folder.FullName);
            // Iterate each file
            foreach (FileInfo file in folder.GetFiles())
            {
                try
                {
                    // Delete the file, ignoring any exceptions
                    file.Delete();
                }
                catch (Exception)
                {
                }
            }

            // For each folder in the specified folder
            foreach (DirectoryInfo subfolder in folder.GetDirectories())
            {
                // Clear all the files in the folder
                ClearFolder(subfolder);
            }
        }
        /// <summary>
        /// Get the web element according to a given page name, frame name and location(identification method for the element)
        ///
        /// </summary>
        /// <param name="pageNameToSwitchTo"></param>
        /// <param name="frameNameToSwitchTo"></param>
        /// <param name="by"></param>
        /// <returns></returns>
        private IWebElement waitAndGetElement(string pageNameToSwitchTo, string frameNameToSwitchTo, params By[] by)
        {
            Exception exception = null;

            SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName());
            String      errorMessage = "No Element Was Found by: " + by[0] + "\n EXCEPTION THROWN: ";
            IWebElement webElement   = null;

            if (waitForAjax)
            {
                //Check the status of the page by executing the javascipt, document.status, to see if the page is fully loaded
                //This check makes the system slower but minimize the risk of failure
                javaScriptCalls.WaitForAjaxCallToFinish();
            }
            //Max time to wait for an element
            long maxTimeToWait = CommonUtilities.GetCurrentTimeMillis() + CommonUtilities.GLOBAL_TIMEOUT_TIME_IN_MSEC;

            while (webElement == null && maxTimeToWait > CommonUtilities.GetCurrentTimeMillis())
            {
                try
                {
                    //Modify the diver by switching page and frame if needed
                    // driver = SwitchToFrameOrWindowByName(driver, pageNameToSwitchTo, frameNameToSwitchTo);

                    if (by.Length == 1)
                    {
                        var webElementList    = driver.FindElements(by[0]);
                        int nrOfFoundElements = webElementList.Count;
                        if (nrOfFoundElements > 1)
                        {
                            foreach (IWebElement webElementFromList in webElementList)
                            {
                                SAFEBBALog.Warning("Tag name element: " + webElementFromList.TagName);
                                SAFEBBALog.Warning("Text element: " + webElementFromList.Text);
                            }

                            errorMessage = "TOO MANY Elements Was Found by: " + by + "\n EXCEPTION THROWN: ";
                            //throw new Exception();
                        }
                        //Create a WebDriver wait to wait for the element to show on the page
                        var webDriverWait = new WebDriverWait(new SystemClock(), driver, TimeSpan.FromSeconds(CommonUtilities.GLOBAL_TIMEOUT_TIME_IN_MSEC / 1000), TimeSpan.FromMilliseconds(500));
                        webElement = webDriverWait.Until(ExpectedConditions.ElementExists(by[0]));
                    }
                    else
                    {
                        var    webElementList = driver.FindElements(by[0]);
                        string byLocator      = by[1].ToString().ToLower().Replace(" ", "");

                        if (byLocator.Contains("by.tagname"))
                        {
                            foreach (IWebElement webElementFromList in webElementList)
                            {
                                string webElementTagName = "by.tagname:" + webElementFromList.TagName.ToLower().Replace(" ", "");
                                SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), "webElementTagName: " + webElementTagName, "byLocator: " + byLocator);
                                if (byLocator.Contains(webElementTagName))
                                {
                                    webElement = webElementFromList;
                                    break;
                                }
                            }
                        }
                        else if (byLocator.Contains("##"))
                        {
                            int    startIndex   = by[1].ToString().IndexOf("#") + 1;
                            int    endIndex     = by[1].ToString().IndexOf("##") - startIndex;
                            string s            = by[1].ToString().Substring(startIndex, endIndex);
                            int    elementIndex = int.Parse(by[1].ToString().Substring(startIndex, endIndex));
                            webElement = webElementList[elementIndex];
                        }
                    }
                }


                catch (Exception e)
                {
                    exception = e;
                    Thread.Sleep(500);
                }
            }

            if (webElement == null)
            {
                throw new DriverServiceNotFoundException(errorMessage + (exception == null? "":exception.ToString()));
            }
            return(webElement);
        }
示例#23
0
 public void SuiteStarted(TestName testName)
 {
     SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName());
     isScreenShotTaken = false;
 }
示例#24
0
 public void TestStarted(TestName testName)
 {
     SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName());
 }
示例#25
0
        public void SeleniumSetup()
        {
            try
            {
                Console.WriteLine("Starting Driver...........");

                String browser = ConfigurationManager.AppSettings["WEB_BROWSER_TO_RUN"];

                var options = new InternetExplorerOptions
                {
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                    EnsureCleanSession = true,
                    //ForceCreateProcessApi=true
                    EnableNativeEvents = false,
                    RequireWindowFocus = false,
                    IgnoreZoomLevel    = true
                };

                ChromeOptions chromeOptions = new ChromeOptions();

                chromeOptions.AddArgument("--test-type");
                chromeOptions.AddArguments("chrome.switches", "--disable-extensions");

                chromeOptions.AddArgument("start-maximized");
                chromeOptions.AddArgument("--enable-automation");
                chromeOptions.AddArgument("test-type=browser");
                chromeOptions.AddArgument("disable-infobars");

                if (browser.Contains("Internet"))
                {
                    driver = new InternetExplorerDriver(TestContext.DeploymentDirectory, options);
                }
                else if (browser.Contains("Chrome"))
                {
                    driver = new ChromeDriver(chromeOptions);
                }

                // driver = new ChromeDriver();
                else
                {
                    driver = null;
                }


                if (driver != null)
                {
                    // Javascript Class
                    javaScriptCalls        = new JavaScriptCalls();
                    javaScriptCalls.Driver = driver;

                    //Find Web Driver
                    findWebDriverElement                 = new FindWebDriverElement();
                    findWebDriverElement.Driver          = driver;
                    findWebDriverElement.JavaScriptCalls = javaScriptCalls;

                    //Operate Web Element
                    operateOnWebDriverElement = new OperateOnWebDriverElement();
                    operateOnWebDriverElement.FindWebDriverElement = findWebDriverElement;
                    operateOnWebDriverElement.JavaScriptCalls      = javaScriptCalls;


                    safeebbalog = new SAFEBBALog();


                    GoToSite(ConfigParameters.WEB_APPLICATION_URL);
                    // driver.Manage().Window.Maximize();
                    //  }
                    // else
                    //  {
                    // SAFEBBALog.Debug("Browser type not specified in the config file...........");
                    //  }
                }
            }
            catch (Exception e)
            {
                SAFEBBALog.Debug("Error Starting Web Driver...........");
                Console.WriteLine(e.StackTrace);
            }
        }
示例#26
0
 public static void setTestCaseErrorMessage(Exception e)
 {
     SAFEBBALog.TestCaseErrorMessage(e);
 }
示例#27
0
        public static void setTestStepFinish(String status, Exception e)
        {
            try
            {
                // Test Step Error & ScreenShot Style
                testStepWorkSheet.Cells[ts_RowIndex, ts_testStepError_ColIndex].Style.WrapText      = true;
                testStepWorkSheet.Cells[ts_RowIndex, ts_testStepScreenShot_ColIndex].Style.WrapText = true;

                if (status.Equals("Pass"))
                {
                    //Set Test Step Result to Pass
                    testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Value = status;

                    testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Green);

                    //set Test Step Error to NA
                    testStepWorkSheet.Cells[ts_RowIndex, ts_testStepError_ColIndex].Value = "NA";

                    //set Test Step Screenshot location to NA
                    testStepWorkSheet.Cells[ts_RowIndex, ts_testStepScreenShot_ColIndex].Value = "NA";

                    if (tc_Hierachy_Counter > 0)
                    {
                        subTestFailure = false;
                    }
                }

                else
                {
                    // Check for sub test case failure
                    if (!subTestFailure)
                    {
                        //Set Test Step Result to Fail
                        testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Value = status;

                        //Set the color of the status
                        testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                        testStepWorkSheet.Cells[ts_RowIndex, ts_testStepResult_ColIndex].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red);



                        //Write Error Message in Excel
                        testStepWorkSheet.Cells[ts_RowIndex, ts_testStepError_ColIndex].Value = e.Message;

                        //set the width of the error column
                        testStepWorkSheet.Column(ts_testStepError_ColIndex).Width = 50;
                        testStepWorkSheet.Cells[ts_RowIndex, ts_testStepError_ColIndex].Style.WrapText = true;
                        testStepWorkSheet.Row(ts_RowIndex).Height = 50;
                        //testStepWorkSheet.Column(ts_testStepError_ColIndex).AutoFit();

                        CommonUtilities.CreateAndSaveScreenShot(resultFolderPath + "\\" + currentTestname + ".png");

                        Thread.Sleep(3 * 1000);

                        var uri = new Uri(resultFolderPath + "\\" + currentTestname + ".png");

                        errorTestResultFilePath = resultFolderPath + "\\" + currentTestname + ".png";

                        var cell = testStepWorkSheet.Cells[ts_RowIndex, ts_testStepScreenShot_ColIndex];

                        //cell.Hyperlink = new Uri(Environment.CurrentDirectory + "\\" + currentTestname + ".png");

                        // cell.Hyperlink = new Uri(Environment.CurrentDirectory + "\\" + currentTestname + ".png");

                        if (!(namedStyle != null))
                        {
                            namedStyle = testStepWorkSheet.Workbook.Styles.CreateNamedStyle("HyperLink");
                            namedStyle.Style.Font.UnderLine = true;
                            namedStyle.Style.Font.Color.SetColor(Color.Blue);
                        }

                        cell.Hyperlink = new ExcelHyperLink(uri.AbsoluteUri.ToString());

                        cell.StyleName = "HyperLink";
                        cell.Value     = currentTestname + ".png";
                        if (tc_Hierachy_Counter > 0)
                        {
                            subTestFailure = true;
                        }
                    }
                }

                //Increment the Row Counter
                ts_RowIndex++;
            }
            catch (Exception ex)
            {
                SAFEBBALog.Info("Error Writing data to excel " + ex);
            }
        }
示例#28
0
 public void FieldUserNameInsert(params string[] userName)
 {
     string name = SAFEBBALog.TestStep(CommonUtilities.GetClassAndMethodName(), userName);
     //operateOnWhiteElements.InsertInToHiddenFieldByIndex(WINDOW_WINDOWS_SECURITY, 0, name);
 }
示例#29
0
 public void ButtonOkClick()
 {
     SAFEBBALog.TestStep(CommonUtilities.GetClassAndMethodName());
     //operateOnWhiteElements.ClickButtonByName(WINDOW_WINDOWS_SECURITY, BUTTON_OK);
 }
示例#30
0
 /// <summary>
 /// Clear the cache for Inernet Explorer
 /// </summary>
 public static void ClearIECache()
 {
     SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName());
     // Clear the special cache folder
     ClearFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));
 }