Exemple #1
0
 internal HtmlAnchorElement(
     IDictionary <string, string> attributes,
     HtmlElement parentElement,
     HtmlPage parentPage)
     : base("a", attributes, parentElement, parentPage)
 {
 }
Exemple #2
0
        internal static HtmlElement Create(string htmlMarkup, HtmlPage parentPage, bool ensureValidMarkup)
        {
            HtmlElementBuilder builder = new HtmlElementBuilder(parentPage);

            builder.EnsureValidMarkup = ensureValidMarkup;
            HtmlElement newElement = builder.CreateElement(htmlMarkup);

            return(newElement);
        }
Exemple #3
0
 /// <summary>
 /// Helper method that attempts to refresh the elements collection of a page
 /// </summary>
 private bool TryPageRefresh(HtmlPage page, out Exception exception)
 {
     exception = null;
     try
     {
         page.Elements.Refresh();
     }
     catch (Exception e)
     {
         exception = e;
         return(false);
     }
     return(true);
 }
Exemple #4
0
 internal HtmlElement(string tagName,
                      IDictionary <string, string> attributes,
                      HtmlElement parentElement,
                      HtmlPage parentPage)
 {
     _innerText              = String.Empty;
     _tagName                = tagName;
     _parentElement          = parentElement;
     _parentPage             = parentPage;
     _canUseTagIndexToLocate = false;
     _startPosition          = -1;
     _endPosition            = -1;
     _attributeDictionary    = new HtmlAttributeDictionary(attributes);
 }
Exemple #5
0
        /// <summary>
        /// Method that gets a reference to an HTML popup page
        /// </summary>
        /// <param name="index">Zero based index of windows opened by driver</param>
        /// <param name="timeoutInSeconds">Timeout to wait for the popup window to finish loading</param>
        /// <param name="waitBetweenAttemptsInMilliseconds">Milliseconds to wait between attempting to get popup page</param>
        /// <returns>HtmlPage to interact with the supplied popup window</returns>
        public HtmlPage GetPopupPage(int index, int timeoutInSeconds = REFRESH_TIMEOUT_DEFAULT, int waitBetweenAttemptsInMilliseconds = 500)
        {
            HtmlPage popupPage = new HtmlPage();

            popupPage.WindowIndex = index;

            Exception exception = null;
            DateTime  timeout   = DateTime.Now.AddSeconds(timeoutInSeconds);

            // Wait until the popup page can be refreshed, or until timeout
            while (!TryPageRefresh(popupPage, out exception) && DateTime.Now < timeout)
            {
                Thread.Sleep(waitBetweenAttemptsInMilliseconds);
            }

            if (exception != null)
            {
                throw new WebTestException(
                          String.Format("Failed to retrieve the popup window after {0} seconds.", timeoutInSeconds),
                          exception);
            }

            return(popupPage);
        }
Exemple #6
0
        /// <summary>
        /// Create a new HtmlElement
        /// </summary>
        /// <param name="tag">HTML tag of the element</param>
        /// <param name="attributes">Attributes defined on the element</param>
        /// <param name="parent">Parent HtmlElement</param>
        /// <param name="page">Page containing the element</param>
        /// <returns>HtmlElement</returns>
        internal static HtmlElement Create(string tag, IDictionary <string, string> attributes, HtmlElement parent, HtmlPage page)
        {
            HtmlElement element = null;

            // Try to use an HtmlElementCreator
            HtmlElementCreator creator = null;

            if (_elementFactory.TryGetValue(tag, out creator))
            {
                // Ignore any exceptions raised during creation
                try { element = creator(tag, attributes, parent, page); }
                catch { }
            }

            // If we don't have a creator for the element or it failed to create,
            // create a default HtmlElement
            if (element == null)
            {
                element = new HtmlElement(tag, attributes, parent, page);
            }

            return(element);
        }
Exemple #7
0
 internal HtmlTableRowElement(
     IDictionary <string, string> attributes,
     HtmlElement parentElement,
     HtmlPage parentPage) : base("tr", attributes, parentElement, parentPage)
 {
 }
Exemple #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="attributes">Attributes</param>
 /// <param name="parentElement">Parent element</param>
 /// <param name="parentPage">Parent page</param>
 internal HtmlImageElement(IDictionary <string, string> attributes, HtmlElement parentElement, HtmlPage parentPage)
     : base("img", attributes, parentElement, parentPage)
 {
 }
 public IBrowserCommandExecutor CreateBrowserCommandExecutor(string applicationPath, HtmlPage page)
 {
     HtmlElementCollection.FindElementTimeout = 5;
     return(new BrowserCommandExecutor());
 }
 internal HtmlElementCollection(IList <HtmlElement> elementCollection, HtmlPage parentPage, HtmlElement parentElement) :
     base(elementCollection)
 {
     _testPage      = parentPage;
     _parentElement = parentElement;
 }
 internal HtmlElementCollection(HtmlPage parentPage)
     : this(new List <HtmlElement>(), parentPage, null)
 {
 }