Пример #1
0
        public IEOperateCore(string url)
        {
            IE = InternetExplorerFactory.GetInternetExplorer(url);

            HWND = new IntPtr(IE.HWND);
            int loopCount = 0;

            while (IE.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE)
            {
                try
                {
                    dom = (HTMLDocumentClass)IE.Document;
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    continue;
                }
                if (dom.readyState.Equals("complete"))
                {
                    break;
                }

                if (loopCount > 2000)
                {
                    throw new Exception("open " + url + " timeout!");
                }
                Thread.Sleep(500);
                loopCount++;
            }
        }
        public override Application LaunchApplication()
        {
            var processes = Process.GetProcessesByName("iexplore");

            foreach (var process in processes)
            {
                try
                {
                    process.Kill();
                }
                catch { }
            }

            string fullPath;
            var    checkoutDir = Environment.GetEnvironmentVariable("checkoutDir");

            if (string.IsNullOrEmpty(checkoutDir))
            {
                fullPath = Path.GetFullPath
                           (
                    Path.Combine
                    (
                        Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                        @"..\..\..\..\..\..\TestApplications\TestSilverlightApplication.Web"
                    )
                           );
            }
            else
            {
                const string pathToApp = @"SilverlightTestApplication";
                fullPath = Path.GetFullPath(Path.Combine(checkoutDir, pathToApp));
            }
            var          appcmd     = string.Format(@"{0}\system32\inetsrv\AppCmd.exe", Environment.GetEnvironmentVariable("windir"));
            var          addArgs    = string.Format("add app /site.name:\"Default Web Site\" /path:/TestSilverlightApplication.Web /physicalPath:\"{0}\"", fullPath);
            const string deleteArgs = "delete app /app.name:\"Default Web Site\\TestSilverlightApplication.Web\"";

            var logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(SilverlightTestConfiguration));

            logger.Info(string.Format("Running {0} {1}", appcmd, deleteArgs));
            Process.Start(appcmd, deleteArgs).WaitForExit();
            logger.Info(string.Format("Running {0} {1}", appcmd, addArgs));
            Process.Start(appcmd, addArgs).WaitForExit();

            InternetExplorerFactory.Plugin();
            var processStartInfo = new ProcessStartInfo
            {
                FileName  = "iexplore.exe",
                Arguments = "http://localhost/TestSilverlightApplication.Web/TestSilverlightApplicationTestPage.aspx"
            };

            return(Application.Launch(processStartInfo));
        }
Пример #3
0
 public void CloseInternetExplorer()
 {
     if (dom != null)
     {
         dom.close();
         dom = null;
     }
     if (IE != null)
     {
         InternetExplorerFactory.CloseInternetExplorer();
         HWND = new IntPtr(0);
     }
 }
Пример #4
0
 public bool IsMatchIEPage(string url)
 {
     return(InternetExplorerFactory.IsMatchIEWindow(url));
 }
Пример #5
0
 public IEOperateCore()
 {
     IE   = InternetExplorerFactory.GetInternetExplorer();
     HWND = new IntPtr(IE.HWND);
 }