Ejemplo n.º 1
0
        protected virtual void AttachBrowser(InternetExplorer ie)
        {
            if (ie != null && this._browser != ie)
            {
                try
                {
                    if (!_browserList.Contains(ie))
                    {
                        _browserList.Add(ie);
                    }

                    this._browser = ie;
                    this._rootHandle = (IntPtr)ie.HWND;
                    int pid = Win32API.GetWindowThreadProcessId(_rootHandle);
                    this._appProcess = Process.GetProcessById(pid);

                    if (this._currentPage == null)
                    {
                        this._currentPage = GetPage(0) as TestIEPage;
                    }
                    GetSize();
                    RegBrowserEvent(ie);
                }
                catch (TestException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new CannotAttachBrowserException("Can not set browser: " + ex.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual ITestPage PageChange(int pageIndex)
        {
            if (pageIndex >= 0 && pageIndex < this._browserList.Count)
            {
                InternetExplorer ie = _browserList[pageIndex];
                try
                {
                    AttachBrowser(ie);
                    ActiveTab(pageIndex);

                    _currentPage = GetPage(pageIndex) as TestIEPage;

                    if (OnSelectPageChange != null)
                    {
                        TestEventArgs e = new TestEventArgs("PageIndex", pageIndex);
                        OnSelectPageChange(this, e);
                    }
                }
                catch (TestException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new CannotAttachBrowserException(ex.ToString());
                }
            }

            return _currentPage;
        }