コード例 #1
0
        // IsVisible

        /// <summary>
        /// Indicates whether the element is visible or not.
        /// See also https://blog.jquery.com/2009/02/20/jquery-1-3-2-released/#visible-hidden-overhauled
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <returns><c>true</c> if the element is visible</returns>
        public static async Task <bool> IsVisibleAsync(this ElementHandle handle)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <bool>("element => element.offsetWidth > 0 && element.offsetHeight > 0").ConfigureAwait(false));
        }
コード例 #2
0
        // IsReadOnly

        /// <summary>
        /// Indicates whether the element is read-only or not.
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <remarks><![CDATA[Elements: <input>, <textarea>]]></remarks>
        /// <returns><c>true</c> if the element is read-only</returns>
        public static async Task <bool> IsReadOnlyAsync(this ElementHandle handle)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <bool>("element => element.readOnly").ConfigureAwait(false));
        }
コード例 #3
0
        // HasClass

        /// <summary>
        /// Indicates whether the element has the specified class or not.
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <param name="className">The class name</param>
        /// <returns><c>true</c> if the element has the specified class</returns>
        public static async Task <bool> HasClassAsync(this ElementHandle handle, string className)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <bool>("(element, className) => element.classList.contains(className)", className).ConfigureAwait(false));
        }
コード例 #4
0
        // ClassName

        /// <summary>
        /// ClassName of the element.
        /// See also https://developer.mozilla.org/en-US/docs/Web/API/Element/className
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <returns>The element <c>className</c></returns>
        public static async Task <string> ClassNameAsync(this ElementHandle handle)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <string>("element => element.className").ConfigureAwait(false));
        }
コード例 #5
0
        // HasContent

        /// <summary>
        /// Indicates whether the element has the specified content or not.
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <param name="content">The content</param>
        /// <remarks>Evaluates <c>node.textContent</c></remarks>
        /// <returns><c>true</c> if the element has the specified content</returns>
        public static async Task <bool> HasContentAsync(this ElementHandle handle, string content)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <bool>("(node, content) => node.textContent.includes(content)", content).ConfigureAwait(false));
        }
 /// <summary>
 /// The value of a specified attribute on the element.
 /// </summary>
 /// <param name="elementHandle">An <see cref="ElementHandle"/></param>
 /// <param name="name">The attribute name</param>
 /// <returns>The attribute value</returns>
 /// <seealso href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute"/>
 public static async Task <string> GetAttributeAsync(this ElementHandle elementHandle, string name)
 {
     return(await elementHandle.EvaluateFunctionWithoutDisposeAsync <string>("(element, name) => element.getAttribute(name)", name).ConfigureAwait(false));
 }
        // HasAttribute

        /// <summary>
        /// Indicates whether the element has the specified attribute or not.
        /// See also https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
        /// </summary>
        /// <param name="handle">An <see cref="ElementHandle"/></param>
        /// <param name="name">The attribute name</param>
        /// <returns><c>true</c> if the element has the specified attribute</returns>
        public static async Task <bool> HasAttributeAsync(this ElementHandle handle, string name)
        {
            handle.GuardFromNull();
            return(await handle.EvaluateFunctionWithoutDisposeAsync <bool>("(element, name) => element.hasAttribute(name)", name).ConfigureAwait(false));
        }