public ElementTag(string tagName, string inputTypes)
        {
            if (tagName != null)
            {
                TagName = tagName.ToLower(CultureInfo.InvariantCulture);
            }

            IsInputElement = IsAnInputElement(tagName);

            // Check arguments
            if (IsInputElement)
            {
                if (UtilityClass.IsNullOrEmpty(inputTypes))
                {
                    throw new ArgumentNullException("inputTypes", String.Format("inputTypes must be set when tagName is '{0}'", tagName));
                }

                InputTypes = inputTypes.ToLower(CultureInfo.InvariantCulture);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override string ToString()
        {
            if (UtilityClass.IsNotNullOrEmpty(Description))
            {
                return(Description);
            }

            StringBuilder description = new StringBuilder();

            description.Append(GetType().Name);

            // Note: Uses unvalidated document to avoid throwing an exception if the document is incorrect.
            if (_document != null)
            {
                description.Append(@" (");
                description.Append(_document.Url);
                description.Append(@")");
            }

            return(description.ToString());
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override string GetAttributeValueImpl(string attributeName)
        {
            var name = attributeName.ToLowerInvariant();
            string value = null;

            if (name.Equals("href"))
            {
                UtilityClass.TryActionIgnoreException(() => value = Url);
            }
            else if (name.Equals("title"))
            {
                UtilityClass.TryActionIgnoreException(() => value = Title);
            }
            else if (name.Equals("hwnd"))
            {
                UtilityClass.TryActionIgnoreException(() => value = hWnd.ToString());
            }
            else
            {
                throw new InvalidAttributeException(attributeName, "IE");
            }

            return value;
        }
Exemplo n.º 4
0
Arquivo: IE.cs Projeto: minskowl/MY
        /// <inheritdoc />
        protected override string GetAttributeValueImpl(string attributeName)
        {
            var    name  = attributeName.ToLowerInvariant();
            string value = null;

            if (name.Equals("href"))
            {
                UtilityClass.TryActionIgnoreException(() => value = ie.LocationURL);
            }
            else if (name.Equals("title"))
            {
                UtilityClass.TryActionIgnoreException(() => value = ((HTMLDocument)ie.Document).title);
            }
            else if (name.Equals("hwnd"))
            {
                UtilityClass.TryActionIgnoreException(() => value = ie.HWND.ToString());
            }
            else
            {
                throw new InvalidAttributeException(attributeName, "IE");
            }

            return(value);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FireFox"/> class.
 /// </summary>
 /// <param name="url">The url to go to</param>
 public FireFox(string url) : this(UtilityClass.CreateUri(url))
 {
 }
Exemplo n.º 6
0
 /// <summary>
 /// Opens a new Internet Explorer and navigates to the given <paramref name="url"/>.
 /// </summary>
 /// <param name="url">The Url to open</param>
 /// <param name="logonDialogHandler">A <see cref="LogonDialogHandler"/> class instanciated with the logon credentials.</param>
 /// <param name="createInNewProcess">if set to <c>true</c> the IE instance is created in a new process.</param>
 /// <remarks>
 /// You could also use one of the overloaded constructors.
 /// </remarks>
 /// <example>
 /// The following example creates a new Internet Explorer instances and navigates to
 /// the WatiN Project website on SourceForge leaving the created Internet Explorer open.
 /// <code>
 /// using WatiN.Core;
 ///
 /// namespace NewIEExample
 /// {
 ///    public class WatiNWebsite
 ///    {
 ///      public WatiNWebsite()
 ///      {
 ///        LogonDialogHandler logon = new LogonDialogHandler("username", "password");
 ///        IE ie = new IE("http://watin.sourceforge.net", logon);
 ///      }
 ///    }
 ///  }
 /// </code>
 /// </example>
 public IE(string url, LogonDialogHandler logonDialogHandler, bool createInNewProcess)
 {
     CreateNewIEAndGoToUri(UtilityClass.CreateUri(url), logonDialogHandler, createInNewProcess);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Opens a new Internet Explorer and navigates to the given <paramref name="url"/>.
 /// </summary>
 /// <param name="url">The Url to open</param>
 /// <param name="logonDialogHandler">A <see cref="LogonDialogHandler"/> class instanciated with the logon credentials.</param>
 /// <remarks>
 /// You could also use one of the overloaded constructors.
 /// </remarks>
 /// <example>
 /// The following example creates a new Internet Explorer instances and navigates to
 /// the WatiN Project website on SourceForge leaving the created Internet Explorer open.
 /// <code>
 /// using WatiN.Core;
 ///
 /// namespace NewIEExample
 /// {
 ///    public class WatiNWebsite
 ///    {
 ///      public WatiNWebsite()
 ///      {
 ///        LogonDialogHandler logon = new LogonDialogHandler("username", "password");
 ///        IE ie = new IE("http://watin.sourceforge.net", logon);
 ///      }
 ///    }
 ///  }
 /// </code>
 /// </example>
 public IE(string url, LogonDialogHandler logonDialogHandler)
 {
     CreateNewIEAndGoToUri(UtilityClass.CreateUri(url), logonDialogHandler, false);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Opens a new Internet Explorer and navigates to the given <paramref name="url"/>.
 /// <note>
 /// When the <see cref="WatiN.Core.IE" />
 /// instance is destroyed the created Internet Explorer window will also be closed.
 /// </note>
 /// </summary>
 /// <param name="url">The URL to open</param>
 /// <param name="createInNewProcess">if set to <c>true</c> the IE instance is created in a new process.</param>
 /// <remarks>
 /// You could also use one of the overloaded constructors.
 /// </remarks>
 /// <example>
 /// The following example creates a new Internet Explorer instances and navigates to
 /// the WatiN Project website on SourceForge.
 /// <code>
 /// using WatiN.Core;
 ///
 /// namespace NewIEExample
 /// {
 ///    public class WatiNWebsite
 ///    {
 ///      public OpenWatiNWebsite()
 ///      {
 ///        IE ie = new IE("http://watin.sourceforge.net");
 ///      }
 ///    }
 ///  }
 /// </code>
 /// </example>
 public IE(string url, bool createInNewProcess)
 {
     CreateNewIEAndGoToUri(UtilityClass.CreateUri(url), null, createInNewProcess);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Opens a new Internet Explorer and navigates to the given <paramref name="url"/>.
 /// <note>
 /// When the <see cref="WatiN.Core.IE" />
 /// instance is destroyed the created Internet Explorer window will also be closed.
 /// </note>
 /// </summary>
 /// <param name="url">The URL to open</param>
 /// <remarks>
 /// You could also use one of the overloaded constructors.
 /// </remarks>
 /// <example>
 /// The following example creates a new Internet Explorer instances and navigates to
 /// the WatiN Project website on SourceForge.
 /// <code>
 /// using WatiN.Core;
 ///
 /// namespace NewIEExample
 /// {
 ///    public class WatiNWebsite
 ///    {
 ///      public OpenWatiNWebsite()
 ///      {
 ///        IE ie = new IE("http://watin.sourceforge.net");
 ///      }
 ///    }
 ///  }
 /// </code>
 /// </example>
 public IE(string url)
 {
     CreateNewIEAndGoToUri(UtilityClass.CreateUri(url), null, false);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Navigates Internet Explorer to the given <paramref name="url" />.
 /// </summary>
 /// <param name="url">The URL to GoTo.</param>
 /// <example>
 /// The following example creates a new Internet Explorer instance and navigates to
 /// the WatiN Project website on SourceForge.
 /// <code>
 /// using WatiN.Core;
 /// 
 /// namespace NewIEExample
 /// {
 ///    public class WatiNWebsite
 ///    {
 ///      public WatiNWebsite()
 ///      {
 ///        IE ie = new IE();
 ///        ie.GoTo("http://watin.sourceforge.net");
 ///      }
 ///    }
 ///  }
 /// </code>
 /// </example>
 public virtual void GoTo(string url)
 {
     GoTo(UtilityClass.CreateUri(url));
 }
Exemplo n.º 11
0
 private static bool IsIEServerWindow(IntPtr hWnd)
 {
     return(UtilityClass.CompareClassNames(hWnd, "Internet Explorer_Server"));
 }
Exemplo n.º 12
0
 internal static bool IsIETridentDlgFrame(IntPtr hWnd)
 {
     return(UtilityClass.CompareClassNames(hWnd, "Internet Explorer_TridentDlgFrame"));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Finds an element, frame, IE instance or HTMLDialog by its Url.
 /// </summary>
 /// <param name="url">The well-formed url to find.</param>
 /// <param name="ignoreQuery">Set to true to ignore querystring when matching.</param>
 /// <returns><see cref="AttributeConstraint" /></returns>
 /// <example>
 /// <code>ie.Link(Find.ByUrl("http://watin.sourceforge.net", true)).Url</code>
 /// </example>
 public static AttributeConstraint ByUrl(string url, bool ignoreQuery)
 {
     return(ByUrl(UtilityClass.CreateUri(url), ignoreQuery));
 }
 /// <summary>
 /// Fires the given event on the given element.
 /// </summary>
 /// <param name="element">Element to fire the event on</param>
 /// <param name="eventName">Name of the event to fire</param>
 public virtual void FireEvent(DispHTMLBaseElement element, string eventName)
 {
     UtilityClass.FireEvent(element, eventName);
 }
 /// <summary>
 /// Runs the script code in IE.
 /// </summary>
 /// <param name="scriptCode">The script code.</param>
 /// <param name="language">The language.</param>
 public void RunScript(string scriptCode, string language)
 {
     UtilityClass.RunScript(scriptCode, language, HtmlDocument.parentWindow);
 }