コード例 #1
0
 /// <summary>
 /// Asserts that the element does not have focus.
 /// </summary>
 /// <param name="elementHandle">An <see cref="ElementHandle"/></param>
 /// <param name="because">A phrase explaining why the assertion is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 /// <remarks><![CDATA[Elements: <button>, <input>, <keygen>, <select>, <textarea>]]></remarks>
 public static async Task ShouldNotHaveFocusAsync(this ElementHandle elementHandle, string because = null)
 {
     if (await elementHandle.HasFocusAsync().ConfigureAwait(false))
     {
         Throw.ShouldNotHaveFocus(elementHandle, because);
     }
 }
コード例 #2
0
 /// <summary>
 /// Asserts that the element does not have focus.
 /// </summary>
 /// <param name="handle">An <see cref="ElementHandle"/></param>
 /// <param name="message">Optional failure message</param>
 /// <remarks><![CDATA[Elements: <button>, <input>, <keygen>, <select>, <textarea>]]></remarks>
 public static async Task ShouldNotHaveFocusAsync(this ElementHandle handle, string message = null)
 {
     if (await handle.HasFocusAsync().ConfigureAwait(false))
     {
         Throw.ShouldNotHaveFocus(handle, message);
     }
 }
コード例 #3
0
 /// <summary>
 /// Indicates whether the element has focus or not.
 /// See also https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement
 /// </summary>
 /// <param name="handle">An <see cref="ElementHandle"/></param>
 /// <remarks><![CDATA[Elements: <button>, <input>, <keygen>, <select>, <textarea>]]></remarks>
 /// <returns><c>true</c> if the element has focus</returns>
 public static bool HasFocus(this ElementHandle handle)
 {
     return(handle.HasFocusAsync().Result());
 }