コード例 #1
0
ファイル: BrowserWindow.cs プロジェクト: windtwf/Myrepos
        /// <summary>
        /// Opens a new browser window
        /// <para>Note: If changing browser types, all windows opened by the previous type must be closed first</para>
        /// </summary>
        /// <param name="url">The URL for the window to navigate to</param>
        /// <param name="webBrowserType">The type of browser to open (e.g. "IE", "Chrome", "Firefox", "Safari")</param>
        /// <param name="closeAllOtherBrowserWindows">If true, all browsers of type webBrowserType will be closed before opening the new window</param>
        /// <param name="maximizeWindow">If true, the new window will be maximized if not already</param>
        public static BrowserWindow Open(string url, string webBrowserType, bool closeAllOtherBrowserWindows = true, bool maximizeWindow = true)
        {
            WebBrowserType browserType = ParseBrowserType(webBrowserType);

            InitializeAgent(browserType);

            if (closeAllOtherBrowserWindows)
            {
                Agent.CloseAllBrowserWindows();
            }

            IWebBrowserWindow _browser = Agent.OpenNewBrowser(url);

            if (maximizeWindow)
            {
                _browser.MaximizeBrowserWindow();
            }

            //hackhack: below waitForDocumentReadyState occasionally raise exception, so catch it then retry to open the browser
            try
            {
                _browser.WaitForDocumentReadyState();
            }
            catch (WebOperationFailedException)
            {
                Agent.CloseAllBrowserWindows();
                _browser = Agent.OpenNewBrowser(url);
                _browser.WaitForDocumentReadyState();
            }

            //Logger.Instance.LogInfo("Opening a browser window, url: " + url + ", browser type: " + webBrowserType);
            //Historian.AddVisistedUrl(url);

            return(new BrowserWindow(_browser));
        }
コード例 #2
0
        public static WebBrowserDriver CreateInstanceForSeleniumServer(WebBrowserType BrowserType, string Server, int Port, string StartURL, string OptionPathForBrowser)
        {
            try
            {
                WebBrowserDriver activeObj = new WebBrowserDriver();
                switch (BrowserType)
                {
                default:
                case WebBrowserType.InternetExplorerForRC:
                    activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser == "" ? "*iexplore" : OptionPathForBrowser, StartURL);
                    break;

                case WebBrowserType.FireFoxForRC:
                    activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser == "" ? "*firefox" : OptionPathForBrowser, StartURL);
                    break;

                case WebBrowserType.ChromeForRC:
                case WebBrowserType.SafariForRC:
                    activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser, StartURL);
                    break;
                }
                activeObj.ActiveBrowserType = BrowserType;
                activeObj.ConnectedType     = SeleniumConnectedType.SeleniumServer;
                activeObj.IsRemoteRC        = true;
                return(activeObj);
            }
            catch (ExtendedExcptions err)
            {
                return(null);
            }
        }
コード例 #3
0
 public static WebBrowserDriver CreateInstanceForSeleniumServer(WebBrowserType BrowserType,string Server,int Port,string StartURL,string OptionPathForBrowser)
 {
     try
     {
         WebBrowserDriver activeObj = new WebBrowserDriver();
         switch (BrowserType)
         {
             default:
             case WebBrowserType.InternetExplorerForRC:
                 activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser == "" ? "*iexplore" : OptionPathForBrowser, StartURL);
                 break;
             case WebBrowserType.FireFoxForRC:
                 activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser == "" ? "*firefox" : OptionPathForBrowser, StartURL);
                 break;
             case WebBrowserType.ChromeForRC:
             case WebBrowserType.SafariForRC:
                 activeObj.ActiveConnectedServerObject = new DefaultSelenium(Server, Port, OptionPathForBrowser, StartURL);
                 break;
         }
         activeObj.ActiveBrowserType = BrowserType;
         activeObj.ConnectedType = SeleniumConnectedType.SeleniumServer;
         activeObj.IsRemoteRC = true;
         return activeObj;
     }
     catch(ExtendedExcptions err)
     {
         return null;
     }
 }
コード例 #4
0
        public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, string entryPointAssembly, WindowGeometry windowGeometry, IEnumerable <string> testAssemblyFormalNames)
        {
            if (methodsToTest == null)
            {
                throw new ArgumentNullException("methodsToTest");
            }
            if (entryPointAssembly == null)
            {
                throw new ArgumentNullException("entryPointAssembly");
            }
            if (unitTestProviderType == UnitTestProviderType.Undefined)
            {
                throw new ArgumentException("Must be defined", "unitTestProviderType");
            }

            if (numberOfBrowserHosts <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0");
            }

            //if (testAssemblyFormalNames.Count() == 0)
            //    throw new ArgumentException("must have some assemblies specified", "testAssemblyFormalNames");

            _methodsToTest           = methodsToTest.ToCollection();
            _tagFilters              = tagFilters ?? string.Empty;
            UnitTestProviderType     = unitTestProviderType;
            NumberOfBrowserHosts     = numberOfBrowserHosts;
            WebBrowserType           = webBrowserType;
            EntryPointAssembly       = entryPointAssembly;
            WindowGeometry           = windowGeometry;
            _testAssemblyFormalNames = new Collection <string>(testAssemblyFormalNames.ToList());
        }
コード例 #5
0
        /// <summary>
        /// 创建测试用例
        /// </summary>
        /// <param name="name"></param>
        /// <param name="testSiteStartUri"></param>
        /// <param name="browserType"></param>
        /// <param name="commands"></param>
        /// <param name="testData"></param>
        /// <returns></returns>
        public static TestCase Create(string name, Uri testSiteStartUri, WebBrowserType browserType, IEnumerable <TestCommand> commands, TestData testData)
        {
            TestCase result = new TestCase(name, testSiteStartUri, browserType);

            if (commands != null && testData != null)
            {
                string   currentFormName = "";
                FormData currentFormData = null;
                foreach (var command in commands)
                {
                    var clonedCommand = command.Clone();
                    if (!String.IsNullOrEmpty(clonedCommand.TargetVarName))
                    {
                        clonedCommand.Target = "";// 原有值必须清空
                    }
                    if (!String.IsNullOrEmpty(clonedCommand.ValueVarName))
                    {
                        clonedCommand.Value = "";// 原有值必须清空
                    }
                    clonedCommand.Value = "";
                    if (!String.IsNullOrEmpty(clonedCommand.FormMark))
                    {
                        if (clonedCommand.IsStartFormMark())
                        {
                            currentFormName = clonedCommand.GetFormName();
                            currentFormData = testData.FindFormData(currentFormName);
                        }
                        else if (clonedCommand.IsEndFormMark())
                        {
                            currentFormName = "";
                        }
                    }

                    if (!String.IsNullOrEmpty(currentFormName) && clonedCommand.IsFormFieldMark())
                    {
                        var fieldName = clonedCommand.ValueVarName;
                        if (currentFormData != null)
                        {
                            clonedCommand.Value = currentFormData.FindFieldValue(fieldName);
                        }
                    }

                    if (clonedCommand.IsAssertMark())
                    {
                        var assertName        = clonedCommand.AssertName;
                        var expectedValueName = clonedCommand.GetAssertVarName();
                        var currentAssertData = testData.FindAssertData(assertName);
                        if (currentAssertData != null)
                        {
                            clonedCommand.SetAssertVarValue(currentAssertData.ExpectedValue);
                        }
                    }

                    result.AddCommand(clonedCommand);
                }
            }
            return(result);
        }
コード例 #6
0
 /// <summary>
 /// 初始化准备
 /// </summary>
 /// <param name="testEngineUri"></param>
 /// <param name="testSiteStartUri"></param>
 /// <param name="browserType"></param>
 /// <param name="commandTimeout"></param>
 public void Prepare(Uri testEngineUri, Uri testSiteStartUri, WebBrowserType browserType, TimeSpan commandTimeout)
 {
     if (IsStarted)
     {
         Stop();
     }
     InternalPrepare(testEngineUri, testSiteStartUri, browserType, commandTimeout);
     IsPrepared = true;
 }
コード例 #7
0
        private static void StartLWAClient(string url, WebBrowserType browserType)
        {
            //make sure to launch LWA Client in case OC is installed
            //if (server_url.EndsWith("?sl=", StringComparison.CurrentCultureIgnoreCase) == false)
            //    server_url += "?sl=";

            Console.WriteLine("Start web browser...");
            WebBrowserLauncher browser = new WebBrowserLauncher(browserType);

            browser.StartWebBrowser(url);
        }
コード例 #8
0
        public StatLightConfiguration GetStatLightConfigurationForDll(UnitTestProviderType unitTestProviderType, string dllPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost)
        {
            if (queryString == null)
                throw new ArgumentNullException("queryString");

            Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>();
            string entryPointAssembly = string.Empty;
            string runtimeVersion = null;
            if (isRemoteRun)
            {
            }
            else
            {
                AssertFileExists(dllPath);

                var dllFileInfo = new FileInfo(dllPath);
                var assemblyResolver = new AssemblyResolver(_logger);
                var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(dllFileInfo.FullName);

                var coreFileUnderTest = new TestFile(dllFileInfo.FullName);
                var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList();
                dependentFilesUnderTest.Add(coreFileUnderTest);
                var xapReadItems = new TestFileCollection(_logger,
                                                          AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(),
                                                          dependentFilesUnderTest);

                SetupUnitTestProviderType(xapReadItems, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

                entryPointAssembly = xapReadItems.TestAssemblyFullName;

                filesToCopyIntoHostXap =()=>
                                            {
                                                return new TestFileCollection(_logger,
                                                                       AssemblyName.GetAssemblyName(dllFileInfo.FullName)
                                                                           .ToString(),
                                                                       dependentFilesUnderTest).FilesContainedWithinXap;
                                            };
            }

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly);

            var serverConfig = CreateServerConfiguration(
                dllPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                DefaultDialogSmackDownElapseMilliseconds,
                queryString,
                forceBrowserStart,
                showTestingBrowserHost,
                runtimeVersion);

            return new StatLightConfiguration(clientConfig, serverConfig);
        }
コード例 #9
0
 public bool OpenWebBrowser(string url, WebBrowserType prefferedType)
 {
     if (prefferedType == WebBrowserType.Overlay)
     {
         return(OpenOverlayWebBrowser(url) || OpenExternalWebBrowser(url));
     }
     else
     {
         return(OpenExternalWebBrowser(url) || OpenOverlayWebBrowser(url));
     }
 }
コード例 #10
0
 public bool OpenWebBrowser(string url, WebBrowserType preferredType)
 {
     App.Log("Opening web browser to {0}", url);
     try
     {
         Process.Start(url);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #11
0
        public IWebBrowser Create(WebBrowserType browserType, Uri pageToHost, bool browserVisible, bool forceBrowserStart, bool isStartingMultipleInstances)
        {
            switch (browserType)
            {
                case WebBrowserType.SelfHosted:
                    return new SelfHostedWebBrowser(_logger, pageToHost, browserVisible);
                case WebBrowserType.Firefox:
                    return new FirefoxWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances);
                case WebBrowserType.Chrome:
                    return new ChromeWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances);
            }

            throw new NotImplementedException();
        }
コード例 #12
0
ファイル: WebBrowserFactory.cs プロジェクト: brumfb/StatLight
        public IWebBrowser Create(WebBrowserType browserType, Uri pageToHost, bool forceBrowserStart, bool isStartingMultipleInstances, WindowGeometry windowGeometry)
        {
            switch (browserType)
            {
                case WebBrowserType.SelfHosted:
                    return new SelfHostedWebBrowser(_logger, pageToHost, windowGeometry.ShouldShowWindow, windowGeometry);
                case WebBrowserType.Firefox:
                    return new FirefoxWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances);
                case WebBrowserType.Chrome:
                    return new ChromeWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances);
            }

            throw new NotImplementedException();
        }
コード例 #13
0
        /// <summary>
        /// 创建测试用例
        /// </summary>
        /// <param name="testScript"></param>
        /// <param name="browserType"></param>
        /// <returns></returns>
        public static TestCase Create(TestScript testScript, WebBrowserType browserType)
        {
            TestCase result = null;

            if (testScript != null)
            {
                result = new TestCase(testScript.Title, new Uri(testScript.StartUrl), browserType);
                foreach (var command in testScript.GetCommandList())
                {
                    var clonedCommand = command.Clone();
                    result.AddCommand(clonedCommand);
                }
            }
            return(result);
        }
コード例 #14
0
        public IWebBrowser Create(WebBrowserType browserType, Uri pageToHost, bool browserVisible, bool forceBrowserStart, bool isStartingMultipleInstances)
        {
            switch (browserType)
            {
            case WebBrowserType.SelfHosted:
                return(new SelfHostedWebBrowser(_logger, pageToHost, browserVisible));

            case WebBrowserType.Firefox:
                return(new FirefoxWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances));

            case WebBrowserType.Chrome:
                return(new ChromeWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances));
            }

            throw new NotImplementedException();
        }
コード例 #15
0
        public IWebBrowser Create(WebBrowserType browserType, Uri pageToHost, bool forceBrowserStart, bool isStartingMultipleInstances, WindowGeometry windowGeometry)
        {
            switch (browserType)
            {
            case WebBrowserType.SelfHosted:
                return(new SelfHostedWebBrowser(_logger, pageToHost, windowGeometry.ShouldShowWindow, windowGeometry));

            case WebBrowserType.Firefox:
                return(new FirefoxWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances));

            case WebBrowserType.Chrome:
                return(new ChromeWebBrowser(_logger, pageToHost, forceBrowserStart, isStartingMultipleInstances));
            }

            throw new NotImplementedException();
        }
コード例 #16
0
        public static void NavigateUrl(EnvDTE.DTE dte, string url, WebBrowserType webBrowserType, string customWebBrowser)
        {
            switch (webBrowserType)
            {
            case WebBrowserType.SystemDefault:
                Process.Start(url);
                break;

            case WebBrowserType.VisualStudio:
                dte.ItemOperations.Navigate(url);
                break;

            case WebBrowserType.CustomWebBrowser:
                Process.Start(string.Format("\"{0}\"", customWebBrowser), url);
                break;
            }
        }
コード例 #17
0
        public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, bool showTestingBrowserHost, string entryPointAssembly)
        {
            if (methodsToTest == null) throw new ArgumentNullException("methodsToTest");
            if (unitTestProviderType == UnitTestProviderType.Undefined)
                throw new ArgumentException("Must be defined", "unitTestProviderType");

            if (numberOfBrowserHosts <= 0)
                throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0");

            _methodsToTest = methodsToTest.ToCollection();
            _tagFilters = tagFilters ?? string.Empty;
            UnitTestProviderType = unitTestProviderType;
            NumberOfBrowserHosts = numberOfBrowserHosts;
            WebBrowserType = webBrowserType;
            ShowTestingBrowserHost = showTestingBrowserHost;
            EntryPointAssembly = entryPointAssembly;
        }
コード例 #18
0
        public IEnumerable <IWebBrowser> CreateWebBrowsers()
        {
            var            statLightConfiguration     = _currentStatLightConfiguration.Current;
            WebBrowserType webBrowserType             = statLightConfiguration.Client.WebBrowserType;
            string         queryString                = statLightConfiguration.Server.QueryString;
            bool           forceBrowserStart          = statLightConfiguration.Server.ForceBrowserStart;
            WindowGeometry windowGeometry             = statLightConfiguration.Client.WindowGeometry;
            int            numberOfBrowserHosts       = statLightConfiguration.Client.NumberOfBrowserHosts;
            var            testPageUrlWithQueryString = new Uri(_webServerLocation.TestPageUrl + "?" + queryString);

            _logger.Debug("testPageUrlWithQueryString = " + testPageUrlWithQueryString);

            List <IWebBrowser> webBrowsers = Enumerable
                                             .Range(1, numberOfBrowserHosts)
                                             .Select(browserI => Create(webBrowserType, testPageUrlWithQueryString, forceBrowserStart, numberOfBrowserHosts > 1, windowGeometry))
                                             .ToList();

            return(webBrowsers);
        }
コード例 #19
0
        public static void LoadSysConfig()
        {
            XmlDocument configDoc = new XmlDocument();

            configDoc.Load(ConfigFilePath);
            XmlElement  rootNode = configDoc.DocumentElement;
            XmlNodeList allNodes = rootNode.SelectNodes("property");
            Dictionary <string, string> properties = new Dictionary <string, string>();

            foreach (XmlNode node in allNodes)
            {
                string name     = node.Attributes["name"].Value;
                string valueStr = node.Attributes["value"].Value;
                properties.Add(name, valueStr);
            }
            SysConfig.AllowShowError         = properties.ContainsKey("AllowShowError") ? bool.Parse(properties["AllowShowError"]) : SysConfig._AllowShowError;
            SysConfig.IntervalDetailPageSave = properties.ContainsKey("IntervalDetailPageSave") ? int.Parse(properties["IntervalDetailPageSave"]) : SysConfig._IntervalDetailPageSave;
            SysConfig.IntervalShowLog        = properties.ContainsKey("IntervalShowLog") ? int.Parse(properties["IntervalShowLog"]) : SysConfig._IntervalShowLog;
            SysConfig.IntervalShowStatus     = properties.ContainsKey("IntervalShowStatus") ? int.Parse(properties["IntervalShowStatus"]) : SysConfig._IntervalShowStatus;
            SysConfig.MaxAliveTaskNum        = properties.ContainsKey("MaxAliveTaskNum") ? int.Parse(properties["MaxAliveTaskNum"]) : SysConfig._MaxAliveTaskNum;
            SysConfig.ServerIP               = properties.ContainsKey("ServerIP") ? properties["ServerIP"] : SysConfig._ServerIP;
            SysConfig.ServerPort             = properties.ContainsKey("ServerPort") ? int.Parse(properties["ServerPort"]) : SysConfig._ServerPort;
            SysConfig.ShowLogLevelType       = properties.ContainsKey("ShowLogLevelType") ? (LogLevelType)Enum.Parse(typeof(LogLevelType), properties["ShowLogLevelType"]) : SysConfig._ShowLogLevelType;
            SysConfig.ShowLogMinTime         = properties.ContainsKey("ShowLogMinTime") ? int.Parse(properties["ShowLogMinTime"]) : SysConfig._ShowLogMinTime;
            SysConfig.TaskMonitorInterval    = properties.ContainsKey("TaskMonitorInterval") ? int.Parse(properties["TaskMonitorInterval"]) : SysConfig._TaskMonitorInterval;
            SysConfig.WebPageEncoding        = properties.ContainsKey("WebPageEncoding") ? properties["WebPageEncoding"] : SysConfig._WebPageEncoding;
            SysConfig.WebPageRequestInterval = properties.ContainsKey("WebPageRequestInterval") ? int.Parse(properties["WebPageRequestInterval"]) : SysConfig._WebPageRequestInterval;
            SysConfig.WebPageRequestTimeout  = properties.ContainsKey("WebPageRequestTimeout") ? int.Parse(properties["WebPageRequestTimeout"]) : SysConfig._WebPageRequestTimeout;
            SysConfig.XPathSplit             = properties.ContainsKey("XPathSplit") ? properties["XPathSplit"] : SysConfig._XPathSplit;
            SysConfig.ProxyAbandonErrorTime  = properties.ContainsKey("ProxyAbandonErrorTime") ? int.Parse(properties["ProxyAbandonErrorTime"]) : SysConfig.ProxyAbandonErrorTime;
            SysConfig.NoneGotTimeout         = properties.ContainsKey("NoneGotTimeout") ? int.Parse(properties["NoneGotTimeout"]) : SysConfig.NoneGotTimeout;
            SysConfig.SysExecuteType         = properties.ContainsKey("SysExecuteType") ? (SysExecuteType)Enum.Parse(typeof(SysExecuteType), properties["SysExecuteType"]) : SysConfig.SysExecuteType;
            SysConfig.BrowserType            = properties.ContainsKey("BrowserType") ? (WebBrowserType)Enum.Parse(typeof(WebBrowserType), properties["BrowserType"]) : SysConfig.BrowserType;

            CefSharp.CefSettings settings = new CefSharp.CefSettings();
            settings.CachePath = "c:\\nda_config\\chromium";

            settings.PersistSessionCookies = true;
            CefSharp.Cef.Initialize(settings);
        }
コード例 #20
0
        public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, string entryPointAssembly, WindowGeometry windowGeometry, IEnumerable<string> testAssemblyFormalNames)
        {
            if (methodsToTest == null) throw new ArgumentNullException("methodsToTest");
            if (entryPointAssembly == null) throw new ArgumentNullException("entryPointAssembly");
            if (unitTestProviderType == UnitTestProviderType.Undefined)
                throw new ArgumentException("Must be defined", "unitTestProviderType");

            if (numberOfBrowserHosts <= 0)
                throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0");

            //if (testAssemblyFormalNames.Count() == 0)
            //    throw new ArgumentException("must have some assemblies specified", "testAssemblyFormalNames");

            _methodsToTest = methodsToTest.ToCollection();
            _tagFilters = tagFilters ?? string.Empty;
            UnitTestProviderType = unitTestProviderType;
            NumberOfBrowserHosts = numberOfBrowserHosts;
            WebBrowserType = webBrowserType;
            EntryPointAssembly = entryPointAssembly;
            WindowGeometry = windowGeometry;
            _testAssemblyFormalNames = new Collection<string>(testAssemblyFormalNames.ToList());
        }
コード例 #21
0
ファイル: BrowserWindow.cs プロジェクト: windtwf/Myrepos
 /// <summary>
 /// Sets and initializes the web framework agent if necessary
 /// </summary>
 /// <exception cref="Exception">Thrown if the browser type is different than the agent's current
 /// browser type and the agent still has attached/open browser windows</exception>
 /// <param name="browserType">The browser to use (ex. Firefox, IE, Chrome, Safari...)</param>
 private static void InitializeAgent(WebBrowserType browserType)
 {
     // Action based upon condition:
     // Agent is null                                          -> Set the agent and initialize it
     // Agent is set
     //     Requested browser type is different than the agent
     //         Agent has attached browser windows             -> Throw exception
     //         Agent has no attached browser windows          -> Get a new agent of the requested browser type and initialize it
     //     Requested browser type is the same as the agent    -> Do nothing
     if (Agent == null || (Agent.BrowserType != browserType && Agent.GetAttachedBrowserWindows().Length == 0))
     {
         Agent = WebAgentFactory.GetAgent(browserType);
         Agent.Initialize();
         //Agent.Logger = Logger.Instance;
     }
     else if (Agent.BrowserType != browserType)
     {
         throw new Exception(string.Format("Current framework agent still has attached windows."
                                           + " All windows attached to the {0} agent must be closed before you can initialize a {1} agent.",
                                           Agent.BrowserType, browserType));
     }
 }
コード例 #22
0
 /// <summary>
 /// Initilizes IWebDriver base on the given WebBrowser name.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static IWebDriver CreateWebDriver(WebBrowserType name)
 {
     switch (name)
     {
     //case WebBrowserType.Firefox:
     //    return new FirefoxDriver();
     //case WebBrowserType.IE:
     //case WebBrowserType.InternetExplorer:
     //    InternetExplorerOptions ieOption = new InternetExplorerOptions();
     //    ieOption.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
     //    ieOption.EnsureCleanSession = true;
     //    ieOption.RequireWindowFocus = true;
     //    return new InternetExplorerDriver(@"./", ieOption);
     //case "safari":
     //    return new RemoteWebDriver(new Uri("http://mac-ip-address:the-opened-port"), DesiredCapabilities.Safari());
     case WebBrowserType.Chrome:
     default:
         var chromeOption = new ChromeOptions();
         chromeOption.AddArguments("--disable-extensions");
         return(new ChromeDriver(chromeOption));
     }
 }
コード例 #23
0
        static public WebBrowserType GetWebBrowserType(string browserType)
        {
            WebBrowserType browser = WebBrowserType.IE;

            if (string.Compare(browserType, "IE", true) == 0)
            {
                browser = WebBrowserType.IE;
            }
            else if (string.Compare(browserType, "FF", true) == 0)
            {
                browser = WebBrowserType.FF;
            }
            else if (string.Compare(browserType, "CH", true) == 0)
            {
                browser = WebBrowserType.CH;
            }
            else if (string.Compare(browserType, "SF", true) == 0)
            {
                browser = WebBrowserType.SF;
            }

            return(browser);
        }
コード例 #24
0
        public static WebBrowserDriver CreateInstanceForWebDriver(WebBrowserType BrowserType)
        {
            try
            {
                WebBrowserDriver activeObj = new WebBrowserDriver();
                switch (BrowserType)
                {
                case WebBrowserType.Chrome:
                    activeObj.ActiveWebDriver = new ChromeDriver();
                    break;

                case WebBrowserType.FireFox:
                    activeObj.ActiveWebDriver = new FirefoxDriver();
                    break;

                case WebBrowserType.InternetExplorer:
                    activeObj.ActiveWebDriver = new InternetExplorerDriver();
                    break;

                case WebBrowserType.Safari:
                    activeObj.ActiveWebDriver = new SafariDriver();
                    break;

                default:
                    activeObj.ActiveWebDriver = new InternetExplorerDriver();
                    break;
                }
                activeObj.ActiveBrowserType = BrowserType;
                activeObj.ConnectedType     = SeleniumConnectedType.WebDriver;
                activeObj.IsRemoteRC        = false;
                return(activeObj);
            }
            catch (ExtendedExcptions err)
            {
                return(null);
            }
        }
コード例 #25
0
        public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, bool showTestingBrowserHost, string entryPointAssembly)
        {
            if (methodsToTest == null)
            {
                throw new ArgumentNullException("methodsToTest");
            }
            if (unitTestProviderType == UnitTestProviderType.Undefined)
            {
                throw new ArgumentException("Must be defined", "unitTestProviderType");
            }

            if (numberOfBrowserHosts <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0");
            }

            _methodsToTest         = methodsToTest.ToCollection();
            _tagFilters            = tagFilters ?? string.Empty;
            UnitTestProviderType   = unitTestProviderType;
            NumberOfBrowserHosts   = numberOfBrowserHosts;
            WebBrowserType         = webBrowserType;
            ShowTestingBrowserHost = showTestingBrowserHost;
            EntryPointAssembly     = entryPointAssembly;
        }
コード例 #26
0
        public IEnumerable <IWebBrowser> CreateWebBrowsers()
        {
            var            statLightConfiguration     = _currentStatLightConfiguration.Current;
            WebBrowserType webBrowserType             = statLightConfiguration.Client.WebBrowserType;
            string         queryString                = statLightConfiguration.Server.QueryString;
            bool           forceBrowserStart          = statLightConfiguration.Server.ForceBrowserStart;
            WindowGeometry windowGeometry             = statLightConfiguration.Client.WindowGeometry;
            int            numberOfBrowserHosts       = statLightConfiguration.Client.NumberOfBrowserHosts;
            var            testPageUrlWithQueryString = new Uri(_webServerLocation.TestPageUrl + "?" + queryString);

            Func <int, IWebBrowser> webBrowserFactoryHelper;

            if (statLightConfiguration.Server.IsPhoneRun)
            {
                webBrowserFactoryHelper = instanceId =>
                {
                    Func <byte[]> hostXap = statLightConfiguration.Server.HostXap;
                    return(CreatePhone(hostXap));
                };
            }
            else
            {
                webBrowserFactoryHelper = instanceId => Create(webBrowserType, testPageUrlWithQueryString,
                                                               forceBrowserStart, numberOfBrowserHosts > 1,
                                                               windowGeometry);
            }

            _logger.Debug("testPageUrlWithQueryString = " + testPageUrlWithQueryString);

            List <IWebBrowser> webBrowsers = Enumerable
                                             .Range(1, numberOfBrowserHosts)
                                             .Select(browserI => webBrowserFactoryHelper(browserI))
                                             .ToList();

            return(webBrowsers);
        }
コード例 #27
0
ファイル: ArgOptions.cs プロジェクト: tr002196/StatLight
        private OptionSet GetOptions()
        {
            var msTestVersions = (from MicrosoftTestingFrameworkVersion version in Enum.GetValues(typeof(MicrosoftTestingFrameworkVersion))
                                  select version).ToDictionary(key => key.ToString().ToLower(), value => value);

            return(new OptionSet()
                   .Add("x|XapPath", "Path to test xap file. (Can specify multiple -x={path1} -x={path2})", v => _xapPaths.Add(v ?? string.Empty), OptionValueType.Required)
                   .Add("e|ExtensionDllPath", "Path to StatLight extension .dll. (Can specify multiple -e={path1} -e={path2})", v => _extensionDllPaths.Add(v ?? string.Empty))
                   .Add("d|Dll", "Assembly to test.", v =>
            {
                if (!string.IsNullOrEmpty(v))
                {
                    _dlls.Add(v);
                }
            })
                   .Add("t|TagFilters", "The tag filter expression used to filter executed tests. (See Microsoft.Silverlight.Testing filter format for how to generate complicated filter expressions) Only available with MSTest.", v => TagFilters = v, OptionValueType.Optional)
                   .Add <string>("c|Continuous", "Runs a single test run, and then monitors the xap for build changes and re-runs the tests automatically.", v => ContinuousIntegrationMode = true)
                   .Add("b|BrowserWindow", "Sets the display visibility and/or size of the StatLight browser window. Leave blank to keep browser window hidden. Specify this flag to have the browser window shown with the default height/width. Or using the following pattern [M|m|n][HEIGHTxWIDTH] you can specify the window state [M|Maximized|m|Minimized|N|Normal][{HEIGHT}x{WIDTH}] to be able to specify a specific size. EX: -b:N800x600 a normal window with a width of 800 and height of 600.",
                        v => WindowGeometry = ParseWindowGeometry(v))
                   .Add("MethodsToTest", "Semicolon seperated list of full method names to execute. EX: --methodsToTest=\"RootNamespace.ChildNamespace.ClassName.MethodUnderTest;RootNamespace.ChildNamespace.ClassName.Method2UnderTest;\"", v =>
            {
                v = v ?? string.Empty;
                MethodsToTest = v.Split(';').Where(w => !string.IsNullOrEmpty(w)).ToCollection();
            })
                   .Add("o|OverrideTestProvider", "Allows you to override the default test provider of MSTest. Pass in one of the following [{0}]".FormatWith(typeof(UnitTestProviderType).FormatEnumString()), v =>
            {
                v = v ?? string.Empty;
                UnitTestProviderType?result = null;

                foreach (var typeName in Enum.GetNames(typeof(UnitTestProviderType)))
                {
                    if (v.Is(typeName))
                    {
                        result = (UnitTestProviderType)Enum.Parse(typeof(UnitTestProviderType), typeName);
                        break;
                    }
                }

                if (!result.HasValue)
                {
                    throw new StatLightException("Could not find an OverrideTestProvider defined as [{0}]. Please specify one of the following [{1}]".FormatWith(v, typeof(UnitTestProviderType).FormatEnumString()));
                }
                UnitTestProviderType = result.Value;
            })
                   .Add("v|Version", "(NOTE: YOU SHOULD NOT HAVE TO DO THIS) - Give a specific Microsoft.Silverlight.Testing build version. Pass in one of the following [{0}]. One example this may come in useful is if you have an assembly in your xap named similar to what StatLight is using to automatically detect the version. You can use this to override the 'figured out type'.".FormatWith(typeof(MicrosoftTestingFrameworkVersion).FormatEnumString()), v =>
            {
                v = v ?? string.Empty;

                if (string.IsNullOrEmpty(v))
                {
                    MicrosoftTestingFrameworkVersion = null;
                }
                else
                {
                    var loweredV = v.ToLower();
                    if (msTestVersions.ContainsKey(loweredV))
                    {
                        MicrosoftTestingFrameworkVersion = msTestVersions[loweredV];
                    }
                    else
                    {
                        throw new StatLightException("Could not find a version defined as [{0}]. Please specify one of the following [{1}]".FormatWith(v, typeof(MicrosoftTestingFrameworkVersion).FormatEnumString()));
                    }
                }
            })
                   .Add("r|ReportOutputFile", "File path to write xml report.", v =>
            {
                v = v ?? string.Empty;
                if (Directory.Exists(Path.GetDirectoryName(v)))
                {
                    XmlReportOutputPath = v;
                }
                else
                {
                    throw new DirectoryNotFoundException("Could not find directory in [{0}]".FormatWith(v));
                }
            })
                   .Add("ReportOutputFileType", "Specify the type of report output when using the -r|--ReportOutputFile=[path]. Possible options [{0}]".FormatWith(typeof(ReportOutputFileType).FormatEnumString()), v =>
            {
                ReportOutputFileType = ParseEnum <ReportOutputFileType>(v);
            })
                   .Add <string>("UseRemoteTestPage", "You can specify a remotly hosted test page (that contains a StatLight remote runner) by specifying -x=http://localhost/pathToTestPage.html and the --UseRemoteTestPage flag to have StatLight spin up a browser to call the remote page.", v => UseRemoteTestPage = true)
                   .Add("WebBrowserType", "If you have other browser installed, you can have StatLight use any of the following web browsers [{0}]".FormatWith(typeof(WebBrowserType).FormatEnumString()), v =>
            {
                _webBrowserType = ParseEnum <WebBrowserType>(v);
            })
                   .Add("ForceBrowserStart", "You may need use this option to give permission for StatLight to forcefully close external web browser processes before starting a test run.", v => ForceBrowserStart = true)
                   .Add("NumberOfBrowserHosts", "Default is 1. Allows you to specify the number of browser windows to spread work across.", v =>
            {
                int value;
                v = v ?? string.Empty;
                if (int.TryParse(v, out value))
                {
                    NumberOfBrowserHosts = value;
                }
                else
                {
                    throw new StatLightException("Could not parse parameter [{0}] for numberofbrowsers into an integer.".FormatWith(v));
                }
            })
                   .Add <string>("UsePhoneEmulator", "If you have the windows phone SDK installed. Attempt this run with the emulator.", v => UsePhoneEmulator = true)
                   .Add("QueryString", "Specify some QueryString that will be appended to the browser test page request. This can be helpful to setup a remote web service and pass in the url, or a port used. You can then access the querystring within silverlight HtmlPage.Document.QueryString[..]", v => QueryString = v ?? String.Empty)
                   .Add <string>("teamcity", "Changes the console output to generate the teamcity message spec.", v => OutputForTeamCity = true)
                   .Add <string>("MSGenericTestFormat", "This option has been replaced. Use the --ReportOutputFileType:MSGenericTestFormat", v =>
            {
                throw new StatLightException("THe --MSGenericTestFormat flag has been removed. You should now be using --ReportOutputFileType:{0}".FormatWith(ReportOutputFileType.MSGenericTest));
            })
                   .Add <string>("webserveronly", "Starts up the StatLight web server without any browser. Useful when needing to attach Visual Studio Debugger to the browser and debug a test.", v => StartWebServerOnly = true)
                   .Add <string>("debug", "Prints a verbose spattering of internal logging information. Useful when trying to understand possible issues or when reporting issues back to StatLight.CodePlex.com", v => IsRequestingDebug = true)
                   .Add("OverrideSetting", "Specify settings to overried at the command line. [EX: --OverrideSetting:MaxWaitTimeAllowedBeforeCommunicationErrorSent=00:00:20", v =>
            {
                if (string.IsNullOrEmpty(v))
                {
                    return;
                }

                var item = v.Split('=');
                if (item.Length != 2)
                {
                    throw new StatLightException("Invalid settings format specified");
                }

                OverriddenSettings.Add(item[0], item[1]);
            })
                   .Add <string>("?|help", "displays the help message", v => ShowHelp = true)
                   );
        }
コード例 #28
0
        public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost)
        {
            if (queryString == null)
                throw new ArgumentNullException("queryString");

            Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>();
            string runtimeVersion = null;
            string entryPointAssembly = string.Empty;
            if (isRemoteRun)
            {
            }
            else
            {
                AssertFileExists(xapPath);

                var xapReader = new XapReader(_logger);

                TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath);
                runtimeVersion = XapReader.GetRuntimeVersion(xapPath);

                SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

                entryPointAssembly = testFileCollection.TestAssemblyFullName;

                filesToCopyIntoHostXap = () =>
                {
                    return xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap;
                };

            }

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly);

            var serverConfig = CreateServerConfiguration(
                xapPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                DefaultDialogSmackDownElapseMilliseconds,
                queryString,
                forceBrowserStart,
                showTestingBrowserHost,
                runtimeVersion);

            return new StatLightConfiguration(clientConfig, serverConfig);
        }
コード例 #29
0
        public static WebBrowserDriver CreateInstanceForWebDriver(WebBrowserType BrowserType)
        {
            try
            {
                WebBrowserDriver activeObj = new WebBrowserDriver();
                switch (BrowserType)
                {
                    case WebBrowserType.Chrome:
                        activeObj.ActiveWebDriver = new ChromeDriver();
                        break;
                    case WebBrowserType.FireFox:
                        activeObj.ActiveWebDriver = new FirefoxDriver();
                        break;
                    case WebBrowserType.InternetExplorer:
                        activeObj.ActiveWebDriver = new InternetExplorerDriver();
                        break;
                    case WebBrowserType.Safari:
                        activeObj.ActiveWebDriver = new SafariDriver();
                        break;
                    default:
                        activeObj.ActiveWebDriver = new InternetExplorerDriver();
                        break;

                }
                activeObj.ActiveBrowserType = BrowserType;
                activeObj.ConnectedType = SeleniumConnectedType.WebDriver;
                activeObj.IsRemoteRC = false;
                return activeObj;
            }
            catch(ExtendedExcptions err)
            {
                return null;
            }
        }
コード例 #30
0
        /// <summary>
        /// 初始化准备
        /// </summary>
        /// <param name="testEngineUri"></param>
        /// <param name="testSiteStartUri"></param>
        /// <param name="browserType"></param>
        /// <param name="commandTimeout"></param>
        protected override void InternalPrepare(Uri testEngineUri, Uri testSiteStartUri, WebBrowserType browserType, TimeSpan commandTimeout)
        {
            DesiredCapabilities aDesiredcap = null;

            switch (browserType)
            {
            case WebBrowserType.Chrome:
                aDesiredcap = DesiredCapabilities.Chrome();
                break;

            case WebBrowserType.Firefox:
                aDesiredcap = DesiredCapabilities.Firefox();
                break;

            case WebBrowserType.InternetExplorer:
                aDesiredcap = DesiredCapabilities.InternetExplorer();
                break;

            case WebBrowserType.Safari:
                aDesiredcap = DesiredCapabilities.Safari();
                break;

            default:
                aDesiredcap = DesiredCapabilities.Chrome();
                break;
            }
            aDesiredcap.Platform = new Platform(PlatformType.Any);
            this.commandTimeout  = commandTimeout;
            var wd = new RemoteWebDriver(testEngineUri, aDesiredcap, commandTimeout);

            selenium = new Selenium.WebDriverBackedSelenium(wd, testSiteStartUri.Scheme + "://" + testSiteStartUri.Authority);
        }
コード例 #31
0
 public InputOptions SetWebBrowserType(WebBrowserType webBrowserType)
 {
     WebBrowserType = webBrowserType;
     return(this);
 }
コード例 #32
0
        public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Collection <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            IEnumerable <ITestFile> filesToCopyIntoHostXap = new List <ITestFile>();
            string entryPointAssembly = string.Empty;

            if (isRemoteRun)
            {
            }
            else
            {
                AssertFileExists(xapPath);

                var xapReader = new XapReader(_logger);

                TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath);

                SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

                entryPointAssembly = testFileCollection.TestAssemblyFullName;

                filesToCopyIntoHostXap = testFileCollection.FilesContainedWithinXap;
            }

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly);

            var serverConfig = CreateServerConfiguration(
                xapPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                DefaultDialogSmackDownElapseMilliseconds,
                queryString,
                forceBrowserStart,
                showTestingBrowserHost);

            return(new StatLightConfiguration(clientConfig, serverConfig));
        }
コード例 #33
0
        static void Main(string[] args)
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);

            string         startUrl      = string.Empty;
            WebBrowserType browser       = WebBrowserType.IE;
            bool           launchBrowser = false;

            foreach (String str in args)
            {
                string param = str.ToLower();
                if (param[0] == '-')
                {
                    param = "/" + param.Substring(1);
                }

                if (param.StartsWith("/map:"))
                {
                    string          mapEntry = str.Substring("/map:".Length).ToLower();
                    ReplaceMapEntry entry    = new ReplaceMapEntry();
                    int             delim    = mapEntry.IndexOf("@@");
                    if (delim >= 0)
                    {
                        string sourcePath = mapEntry.Substring(0, delim);
                        sourcePath = sourcePath.Replace("http://", "");
                        sourcePath = sourcePath.Replace("https://", "");
                        sourcePath = sourcePath.Replace("file://", "");

                        string destinationPath = mapEntry.Substring(delim + 2);

                        //check replaced files
                        Util.IsExisting(destinationPath);

                        //check is dest is file or folder
                        if (File.Exists(destinationPath))
                        {
                            //replacement is a file
                            if (!sourcePath.EndsWith(".js") &&
                                !sourcePath.EndsWith(".css") &&
                                !sourcePath.EndsWith(".png") &&
                                !sourcePath.EndsWith(".html") &&
                                !sourcePath.EndsWith(".htm"))
                            {
                                Usage();
                            }
                        }
                        else
                        {
                            //replacement is a folder
                            if (!sourcePath.EndsWith("/"))
                            {
                                sourcePath += "/";
                            }

                            if (!destinationPath.EndsWith("\\"))
                            {
                                destinationPath += "\\";
                            }
                        }

                        entry.sourcePath      = sourcePath;
                        entry.destinationPath = destinationPath;
                        replaceMap.Add(entry);
                    }
                }
                else if (param.StartsWith("/url:"))
                {
                    startUrl      = str.Substring("/url:".Length);
                    launchBrowser = true;
                }
                else if (param.StartsWith("/browser:"))
                {
                    browser       = WebBrowserLauncher.GetWebBrowserType(str.Substring("/browser:".Length));
                    launchBrowser = true;
                }
                else
                {
                    Usage();
                }
            }

            if (replaceMap.Count <= 0)
            {
                Usage();
            }

            CleanUpBrowserCache();

            try
            {
                InitializeFiddler();

                if (launchBrowser)
                {
                    StartLWAClient(startUrl, browser);
                }

                bool done = false;
                do
                {
                    Console.WriteLine("Enter a command [ctrl+c or q=quit]:");
                    Console.Write(">");

                    ConsoleKeyInfo cki = Console.ReadKey(true);
                    switch (cki.KeyChar)
                    {
                    case 'q':
                    case 'Q':
                        done = true;
                        DoQuit();
                        break;

                    default:
                        Console.WriteLine();
                        break;
                    }
                } while (!done);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                //in case an exception thrown, always do clear up work: close log, shutdown fiddler
                //FiddlerCore change IE proxy settings, make sure to revert it
                DoQuit();
            }
        }
コード例 #34
0
        public StatLightConfiguration GetStatLightConfigurationForDll(UnitTestProviderType unitTestProviderType, string dllPath, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Collection <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            IEnumerable <ITestFile> filesToCopyIntoHostXap = new List <ITestFile>();
            string entryPointAssembly = string.Empty;

            if (isRemoteRun)
            {
            }
            else
            {
                AssertFileExists(dllPath);

                var dllFileInfo = new FileInfo(dllPath);

                var assemblyResolver    = new AssemblyResolver(_logger, dllFileInfo.Directory);
                var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(dllFileInfo.FullName);

                var coreFileUnderTest       = new TestFile(dllFileInfo.FullName);
                var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList();
                dependentFilesUnderTest.Add(coreFileUnderTest);

                var xapReadItems = new TestFileCollection(_logger,
                                                          AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(),
                                                          dependentFilesUnderTest);

                SetupUnitTestProviderType(xapReadItems, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

                entryPointAssembly = xapReadItems.TestAssemblyFullName;

                filesToCopyIntoHostXap = xapReadItems.FilesContainedWithinXap;
            }

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly);

            var serverConfig = CreateServerConfiguration(
                dllPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                DefaultDialogSmackDownElapseMilliseconds,
                queryString,
                forceBrowserStart,
                showTestingBrowserHost);

            return(new StatLightConfiguration(clientConfig, serverConfig));
        }
コード例 #35
0
        public TestReportCollection Run()
        {
            bool showTestingBrowserHost       = _options.ShowTestingBrowserHost;
            bool useRemoteTestPage            = _options.UseRemoteTestPage;
            Collection <string> methodsToTest = _options.MethodsToTest;
            MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion;
            string tagFilters = _options.TagFilters;
            UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType;
            int            numberOfBrowserHosts       = _options.NumberOfBrowserHosts;
            string         queryString       = _options.QueryString;
            WebBrowserType webBrowserType    = _options.WebBrowserType;
            bool           forceBrowserStart = _options.ForceBrowserStart;

            IEnumerable <string> xapPaths = _options.XapPaths;
            IEnumerable <string> testDlls = _options.Dlls;

            _options.DumpValuesForDebug(_logger);

            var runnerType = GetRunnerType();

            _logger.Debug("RunnerType = {0}".FormatWith(runnerType));

            var testReports = new TestReportCollection();

            foreach (var xapPath in xapPaths)
            {
                _logger.Debug("Starting configuration for: {0}".FormatWith(xapPath));
                StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory
                                                                .GetStatLightConfigurationForXap(
                    unitTestProviderType,
                    xapPath,
                    microsoftTestingFrameworkVersion,
                    methodsToTest,
                    tagFilters,
                    numberOfBrowserHosts,
                    useRemoteTestPage,
                    queryString,
                    webBrowserType,
                    forceBrowserStart,
                    showTestingBrowserHost);

                var testReport = DoTheRun(runnerType, statLightConfiguration);
                testReports.Add(testReport);
            }

            foreach (var dllPath in testDlls)
            {
                _logger.Debug("Starting configuration for: {0}".FormatWith(dllPath));
                StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory
                                                                .GetStatLightConfigurationForDll(
                    unitTestProviderType,
                    dllPath,
                    microsoftTestingFrameworkVersion,
                    methodsToTest,
                    tagFilters,
                    numberOfBrowserHosts,
                    useRemoteTestPage,
                    queryString,
                    webBrowserType,
                    forceBrowserStart,
                    showTestingBrowserHost);

                var testReport = DoTheRun(runnerType, statLightConfiguration);
                testReports.Add(testReport);
            }

            string        xmlReportOutputPath = _options.XmlReportOutputPath;
            bool          tfsGenericReport    = _options.TFSGenericReport;
            XmlReportType xmlReportType       = XmlReportType.StatLight;

            if (tfsGenericReport)
            {
                xmlReportType = XmlReportType.TFS;
            }

            WriteXmlReport(testReports, xmlReportOutputPath, xmlReportType);

            return(testReports);
        }
コード例 #36
0
 private TestCase(string name, Uri testSiteStartUri, WebBrowserType browserType)
 {
     Name             = name;
     TestSiteStartUri = testSiteStartUri;
     BrowserType      = browserType;
 }
コード例 #37
0
        public static IWebDriver CreateWebDriver(Assembly executingAssembly, WebBrowserType webBrowserType, string webDriverEmbededResourceManifestName = "")
        {
            if (webBrowserType != WebBrowserType.FireFox)
            {
                ExtractWebDriverFromEmbeddedResource(executingAssembly, webDriverEmbededResourceManifestName);
            }

            IWebDriver webDriver = _webDrivers[webBrowserType].Invoke();

            return webDriver;
        }
コード例 #38
0
ファイル: InputOptions.cs プロジェクト: brumfb/StatLight
 public InputOptions SetWebBrowserType(WebBrowserType webBrowserType)
 {
     WebBrowserType = webBrowserType;
     return this;
 }
コード例 #39
0
 public WebBrowserLauncher(WebBrowserType browserType)
 {
     this.browserType = browserType;
 }
コード例 #40
0
 public WebBrowserLauncher(string browserType)
 {
     this.browserType = GetWebBrowserType(browserType);
 }