示例#1
0
        /// <summary>
        /// Create BrowserAdapter based on configuration
        /// </summary>
        /// <param name="config">BrowserAdapter configuration</param>
        /// <param name="driver">Existing driver, if null the driver will be created using provided configuration</param>
        public static BrowserAdapter Create(BrowserAdapterConfig config, RemoteWebDriver driver = null)
        {
            var browserAdapter = new BrowserAdapter();

            config.DownloadDirPath = browserAdapter.downloaDirectory.Path;
            browserAdapter.Driver  = driver ?? new SeleniumDriverFactory(config).CreateDriver();
            var browserCameraConfig = config.BrowserCameraConfig ?? BrowserCameraConfig.CreateDefault();

            browserAdapter.browserCamera      = BrowserCameraFactory.CreateNew(browserAdapter.Driver, browserCameraConfig);
            browserAdapter.errorBrowserCamera = BrowserCameraFactory.CreateErrorBrowserCamera(browserAdapter.Driver);
            var navigator = new Navigator(browserAdapter.Driver, config.PageUrl, config.MeasureEndpointCoverage);

            browserAdapter.navigator = navigator;
            browserAdapter.supportedInputsAdapters = config.InputAdapters.ToList();
            browserAdapter.SetupBrowserDimensions(config.BrowserDimensions);
            browserAdapter.BrowserName                   = config.BrowserType.ToString();
            browserAdapter.NumberOfInputSetRetries       = config.NumberOfInputSetRetries;
            browserAdapter.AfterFieldValueSetAction      = config.AfterFieldValueSetAction;
            browserAdapter.errorReportBuilder            = TelluriumErrorReportBuilderFactory.Create(config);
            browserAdapter.endpointCoverageReportBuilder = EndpointCoverageReportBuilderFactory.Create(config, navigator);
            browserAdapter.errorScreenshotStorage        = ScreenshotStorageFactory.CreateForErrorScreenshot(config);
            if (config.AnimationsDisabled)
            {
                browserAdapter.navigator.PageReload += (sender, args) => browserAdapter.Driver.DisableAnimations();
            }
            return(browserAdapter);
        }
示例#2
0
        private void ReportError(BrowserAdapterConfig config, Exception exception)
        {
            string screenshotName    = $"{BrowserName}_Error{DateTime.Now:yyyy_MM_dd__HH_mm_ss}";
            var    screenshotRawData = errorBrowserCamera.TakeScreenshot();
            var    storage           = ScreenshotStorageFactory.CreateForErrorScreenshot(config);

            if (screenshotRawData != null)
            {
                storage?.Persist(screenshotRawData, screenshotName);
                errorReportBuilder.ReportException(exception, screenshotRawData, screenshotName);
            }
            else
            {
                errorReportBuilder.ReportException(exception);
            }
        }