/// <summary>
        /// Waits until the <paramref name="regex" /> matches some text inside the HTML Body element contains the given <paramref name="text" />.
        /// </summary>
        /// <param name="regex">The regular expression to match with.</param>
        /// <param name="timeOut">The number of seconds to wait</param>
        /// <returns>
        ///     <see name="TimeoutException"/> if the specified text is not found within the time out period.
        /// </returns>
        public void WaitUntilContainsText(Regex regex, int timeOut)
        {
            SimpleTimer timer = new SimpleTimer(timeOut);

            do
            {
                if (ContainsText(regex))
                {
                    return;
                }

                Thread.Sleep(50);
            } while (!timer.Elapsed);

            throw new WatiN.Core.Exceptions.TimeoutException(string.Format("waiting {0} seconds for document to contain regex '{1}'.", Settings.WaitUntilExistsTimeOut, regex));
        }
 /// <summary>
 /// This method is called to initialise the start time for
 /// determining a time out. It's set to the current time.
 /// </summary>
 /// <returns></returns>
 protected virtual SimpleTimer InitTimeout()
 {
     _timer = null;
     return(Timer);
 }
Exemplo n.º 3
0
	    /// <summary>
        /// Waits until the <paramref name="regex" /> matches some text inside the HTML Body element contains the given <paramref name="text" />.
        /// </summary>
        /// <param name="regex">The regular expression to match with.</param>
        /// <param name="timeOut">The number of seconds to wait</param>
        /// <returns>
        ///     <see name="TimeoutException"/> if the specified text is not found within the time out period.
        /// </returns>
        public void WaitUntilContainsText(Regex regex, int timeOut)
        {
            SimpleTimer timer = new SimpleTimer(timeOut);

            do
            {
                if (ContainsText(regex)) { return; }

                Thread.Sleep(50);
            } while (!timer.Elapsed);

            throw new WatiN.Core.Exceptions.TimeoutException(string.Format("waiting {0} seconds for document to contain regex '{1}'.", Settings.WaitUntilExistsTimeOut, regex));
        }
Exemplo n.º 4
0
 /// <summary>
 /// This method is called to initialise the start time for
 /// determining a time out. It's set to the current time.
 /// </summary>
 /// <returns></returns>
 protected virtual SimpleTimer InitTimeout()
 {
     _waitForCompleteTimeout = new SimpleTimer(_waitForCompleteTimeOut);
     return(_waitForCompleteTimeout);
 }
 /// <summary>
 /// This method is called to initialise the start time for
 /// determining a time out. It's set to the current time.
 /// </summary>
 /// <returns></returns>
 public virtual SimpleTimer InitTimeout()
 {
     _timer = null;
     return(Timer);
 }
Exemplo n.º 6
0
		private static SHDocVw.InternetExplorer findInternetExplorer(BaseConstraint findBy, int timeout)
		{
			Logger.LogAction("Busy finding Internet Explorer matching constriant " + findBy.ConstraintToString());

			SimpleTimer timeoutTimer = new SimpleTimer(timeout);

			do
			{
				Thread.Sleep(500);

				SHDocVw.InternetExplorer internetExplorer = findInternetExplorer(findBy);

				if (internetExplorer != null)
				{
					return internetExplorer;
				}
			} while (!timeoutTimer.Elapsed);

			return null;
		}
Exemplo n.º 7
0
		private SHDocVw.InternetExplorer CreateIEInNewProcess()
		{
			Process m_Proc = Process.Start("IExplore.exe", "about:blank");

			const int timeout = 5000;
			SimpleTimer timeoutTimer = new SimpleTimer(timeout);

			do
			{
				m_Proc.Refresh();
				int mainWindowHandle = (int) m_Proc.MainWindowHandle;

				if (mainWindowHandle != 0)
				{
					return findInternetExplorer(new AttributeConstraint("hwnd", mainWindowHandle.ToString()), Core.Settings.AttachToIETimeOut);
				}
			    Thread.Sleep(500);
			} while (!timeoutTimer.Elapsed);

			throw new IENotFoundException("hwnd not zero", timeout);
		}
Exemplo n.º 8
0
		private HtmlDialog findHtmlDialog(BaseConstraint findBy, int timeout)
		{
			Logger.LogAction("Busy finding HTMLDialog matching criteria: " + findBy.ConstraintToString());

			SimpleTimer timeoutTimer = new SimpleTimer(timeout);

			do
			{
				Thread.Sleep(500);

				foreach (HtmlDialog htmlDialog in HtmlDialogs)
				{
					if (findBy.Compare(htmlDialog))
					{
						return htmlDialog;
					}
				}
			} while (!timeoutTimer.Elapsed);

			throw new HtmlDialogNotFoundException(findBy.ConstraintToString(), timeout);
		}
Exemplo n.º 9
0
		/// <summary>
		/// This method is called to initialise the start time for
		/// determining a time out. It's set to the current time.
		/// </summary>
		/// <returns></returns>
		protected virtual SimpleTimer InitTimeout()
		{
		    _waitForCompleteTimeout = new SimpleTimer(_waitForCompleteTimeOut);
			return _waitForCompleteTimeout;
		}