Esempio n. 1
0
        private void UpdateProgress(TestContextImpl context, TestStep step, int stepCount)
        {
            var msg = string.Format(
                CultureInfo.CurrentCulture,
                Properties.Resources.Progress_Info,
                step.Index + 1,
                stepCount,
                context.TestSequence.FailedCount()) + Environment.NewLine + step.ToString();

            this.Progress.Update(step.Index, stepCount, msg);
            TaskbarManager.Instance.SetProgressValue(this.Progress.Percentage, 100);
        }
Esempio n. 2
0
        private void CreateEvidence(TestContextImpl context, TestStep step)
        {
            ITakesScreenshot takesScreenshot = context.Driver as ITakesScreenshot;

            if (null == takesScreenshot)
            {
                return;
            }

            bool isAlertPresent = false;

            try
            {
                IAlert alert = context.Driver.SwitchTo().Alert();
                isAlertPresent = true;
            }
            catch (OpenQA.Selenium.NoAlertPresentException)
            {
                isAlertPresent = false;
            }

            if (isAlertPresent)
            {
                return;
            }

            Excel.Workbook  workbook          = context.WorkbookContext.Workbook;
            Excel.Worksheet evidenceWorksheet = context.WorkbookContext.AddEvidence();
            Excel.Range     range             = ListRowHelper.Set(step.ListRow, ListRowHelper.ColumnIndex.Evidence, evidenceWorksheet.Name);

            ExcelHelper.SetText(evidenceWorksheet, 1, 1, Properties.Resources.Evidence_Scenario, false).ColumnWidth = 20;

            ExcelHelper.AddHyperLink(
                step.Worksheet,
                range,
                evidenceWorksheet,
                evidenceWorksheet.Cells[1, 1]);

            ExcelHelper.AddHyperLink(
                evidenceWorksheet,
                evidenceWorksheet.Cells[1, 2],
                step.Worksheet,
                range);

            ExcelHelper.SetText(evidenceWorksheet, 2, 1, Properties.Resources.Evidence_Command, false);
            ExcelHelper.SetText(evidenceWorksheet, 2, 2, step.ToString(), false);

            ExcelHelper.SetText(evidenceWorksheet, 3, 1, Properties.Resources.Evidence_ErrorMessage, false);
            ExcelHelper.SetText(evidenceWorksheet, 3, 2, step.ErrorMessage, false);

            ExcelHelper.SetText(evidenceWorksheet, 4, 1, Properties.Resources.Evidence_Browser, false);
            ExcelHelper.SetText(evidenceWorksheet, 4, 2, App.Context.Settings.WebDriverType.ToString(), false);

            ExcelHelper.SetText(evidenceWorksheet, 5, 1, Properties.Resources.Evidence_Title, false);
            ExcelHelper.SetText(evidenceWorksheet, 5, 2, context.Driver.Title, false);

            ExcelHelper.SetText(evidenceWorksheet, 6, 1, Properties.Resources.Evidence_Url, false);
            ExcelHelper.SetText(evidenceWorksheet, 6, 2, context.Driver.Url, false);

            ExcelHelper.SetText(evidenceWorksheet, 7, 1, Properties.Resources.Evidence_Time, false);
            ExcelHelper.SetText(evidenceWorksheet, 7, 2, DateTime.Now.ToString(), false);

            string path = Path.Combine(App.TempDir, Guid.NewGuid().ToString()) + ".jpg";

            try
            {
                Screenshot screenshot = takesScreenshot.GetScreenshot();
                screenshot.SaveAsFile(path, ImageFormat.Jpeg);

                Excel.Shape shape = evidenceWorksheet.Shapes.AddPicture(
                    path,
                    Microsoft.Office.Core.MsoTriState.msoFalse,
                    Microsoft.Office.Core.MsoTriState.msoTrue,
                    0,
                    150,
                    0,
                    0);

                shape.ScaleWidth(1, Microsoft.Office.Core.MsoTriState.msoTrue);
                shape.ScaleHeight(1, Microsoft.Office.Core.MsoTriState.msoTrue);
            }
            finally
            {
                File.Delete(path);
            }
        }