/*
* MIT License
*
* Copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
#nullable enable
namespace Microsoft.Playwright
{
public class ElementHandleTapOptions
{
public ElementHandleTapOptions() { }
public ElementHandleTapOptions(ElementHandleTapOptions clone)
{
if (clone == null)
{
return;
}
Force = clone.Force;
Modifiers = clone.Modifiers;
NoWaitAfter = clone.NoWaitAfter;
Position = clone.Position;
Timeout = clone.Timeout;
Trial = clone.Trial;
}
/// <summary>
/// <para>
/// Whether to bypass the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks. Defaults to <c>false</c>.
/// </para>
/// </summary>
[JsonPropertyName("force")]
public bool? Force { get; set; }
/// <summary>
/// <para>
/// Modifier keys to press. Ensures that only these modifiers are pressed during the
/// operation, and then restores current modifiers back. If not specified, currently
/// pressed modifiers are used.
/// </para>
/// </summary>
[JsonPropertyName("modifiers")]
public IEnumerable<KeyboardModifier>? Modifiers { get; set; }
/// <summary>
/// <para>
/// Actions that initiate navigations are waiting for these navigations to happen and
/// for pages to start loading. You can opt out of waiting via setting this flag. You
/// would only need this option in the exceptional cases such as navigating to inaccessible
/// pages. Defaults to <c>false</c>.
/// </para>
/// </summary>
[JsonPropertyName("noWaitAfter")]
public bool? NoWaitAfter { get; set; }
/// <summary>
/// <para>
/// A point to use relative to the top-left corner of element padding box. If not specified,
/// uses some visible point of the element.
/// </para>
/// </summary>
[JsonPropertyName("position")]
public Position? Position { get; set; }
/// <summary>
/// <para>
/// Maximum time in milliseconds, defaults to 30 seconds, pass <c>0</c> to disable timeout.
/// The default value can be changed by using the <see cref="IBrowserContext.SetDefaultTimeout"/>
/// or <see cref="IPage.SetDefaultTimeout"/> methods.
/// </para>
/// </summary>
[JsonPropertyName("timeout")]
public float? Timeout { get; set; }
/// <summary>
/// <para>
/// When set, this method only performs the <a href="https://playwright.dev/dotnet/docs/actionability">actionability</a>
/// checks and skips the action. Defaults to <c>false</c>. Useful to wait until the
/// element is ready for the action without performing it.
/// </para>
/// </summary>
[JsonPropertyName("trial")]
public bool? Trial { get; set; }
}
}
#nullable disable
/*
* MIT License
*
* Copyright (c) 2020 DarÃo Kondratiuk
* Modifications copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Playwright.Helpers;
using Microsoft.Playwright.Transport.Channels;
using Microsoft.Playwright.Transport.Protocol;
namespace Microsoft.Playwright.Core
{
internal partial class ElementHandle : JSHandle, IElementHandle, IChannelOwner<ElementHandle>
{
private readonly ElementHandleChannel _channel;
internal ElementHandle(IChannelOwner parent, string guid, ElementHandleInitializer initializer) : base(parent, guid, initializer)
{
_channel = new(guid, parent.Connection, this);
_channel.PreviewUpdated += (_, e) => Preview = e.Preview;
}
ChannelBase IChannelOwner.Channel => _channel;
IChannel<ElementHandle> IChannelOwner<ElementHandle>.Channel => _channel;
internal IChannel<ElementHandle> ElementChannel => _channel;
public async Task<IElementHandle> WaitForSelectorAsync(string selector, ElementHandleWaitForSelectorOptions options = default)
=> (await _channel.WaitForSelectorAsync(
selector: selector,
state: options?.State,
timeout: options?.Timeout,
strict: options?.Strict).ConfigureAwait(false))?.Object;
public Task WaitForElementStateAsync(ElementState state, ElementHandleWaitForElementStateOptions options = default)
=> _channel.WaitForElementStateAsync(state, timeout: options?.Timeout);
public Task PressAsync(string key, ElementHandlePressOptions options = default)
=> _channel.PressAsync(
key,
delay: options?.Delay,
timeout: options?.Timeout,
noWaitAfter: options?.NoWaitAfter);
public Task TypeAsync(string text, ElementHandleTypeOptions options = default)
=> _channel.TypeAsync(text, delay: options?.Delay, timeout: options?.Timeout, noWaitAfter: options?.NoWaitAfter);
public async Task<byte[]> ScreenshotAsync(ElementHandleScreenshotOptions options = default)
{
options ??= new();
if (options.Type == null && !string.IsNullOrEmpty(options.Path))
{
options.Type = DetermineScreenshotType(options.Path);
}
byte[] result = await _channel.ScreenshotAsync(
options.Path,
options.OmitBackground,
options.Type,
options.Quality,
options.Mask,
options.Animations,
options.Caret,
options.Scale,
options.Timeout).ConfigureAwait(false);
if (!string.IsNullOrEmpty(options.Path))
{
Directory.CreateDirectory(new FileInfo(options.Path).Directory.FullName);
File.WriteAllBytes(options.Path, result);
}
return result;
}
public Task FillAsync(string value, ElementHandleFillOptions options = default)
=> _channel.FillAsync(
value,
noWaitAfter: options?.NoWaitAfter,
force: options?.Force,
timeout: options?.Timeout);
public async Task<IFrame> ContentFrameAsync() => (await _channel.ContentFrameAsync().ConfigureAwait(false))?.Object;
public Task HoverAsync(ElementHandleHoverOptions options = default)
=> _channel.HoverAsync(
modifiers: options?.Modifiers,
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
trial: options?.Trial);
public Task ScrollIntoViewIfNeededAsync(ElementHandleScrollIntoViewIfNeededOptions options = default)
=> _channel.ScrollIntoViewIfNeededAsync(options?.Timeout);
public async Task<IFrame> OwnerFrameAsync() => (await _channel.OwnerFrameAsync().ConfigureAwait(false)).Object;
public Task<ElementHandleBoundingBoxResult> BoundingBoxAsync() => _channel.BoundingBoxAsync();
public Task ClickAsync(ElementHandleClickOptions options = default)
=> _channel.ClickAsync(
delay: options?.Delay,
button: options?.Button,
clickCount: options?.ClickCount,
modifiers: options?.Modifiers,
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
public Task DblClickAsync(ElementHandleDblClickOptions options = default)
=> _channel.DblClickAsync(
delay: options?.Delay,
button: options?.Button,
modifiers: options?.Modifiers,
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
public Task SetInputFilesAsync(string files, ElementHandleSetInputFilesOptions options = default)
=> SetInputFilesAsync(new[] { files }, options);
public async Task SetInputFilesAsync(IEnumerable<string> files, ElementHandleSetInputFilesOptions options = default)
{
var frame = await OwnerFrameAsync().ConfigureAwait(false);
if (frame == null)
{
throw new PlaywrightException("Cannot set input files to detached element.");
}
var converted = await SetInputFilesHelpers.ConvertInputFilesAsync(files, (BrowserContext)frame.Page.Context).ConfigureAwait(false);
if (converted.Files != null)
{
await _channel.SetInputFilesAsync(converted.Files, options?.NoWaitAfter, options?.Timeout).ConfigureAwait(false);
}
else
{
await _channel.SetInputFilePathsAsync(converted?.LocalPaths, converted?.Streams, options?.NoWaitAfter, options?.Timeout).ConfigureAwait(false);
}
}
public Task SetInputFilesAsync(FilePayload files, ElementHandleSetInputFilesOptions options = default)
=> SetInputFilesAsync(new[] { files }, options);
public async Task SetInputFilesAsync(IEnumerable<FilePayload> files, ElementHandleSetInputFilesOptions options = default)
{
var converted = SetInputFilesHelpers.ConvertInputFiles(files);
await _channel.SetInputFilesAsync(converted.Files, options?.NoWaitAfter, options?.Timeout).ConfigureAwait(false);
}
public async Task<IElementHandle> QuerySelectorAsync(string selector)
=> (await _channel.QuerySelectorAsync(selector).ConfigureAwait(false))?.Object;
public async Task<IReadOnlyList<IElementHandle>> QuerySelectorAllAsync(string selector)
=> (await _channel.QuerySelectorAllAsync(selector).ConfigureAwait(false)).Select(e => ((ElementHandleChannel)e).Object).ToList().AsReadOnly();
public async Task<JsonElement?> EvalOnSelectorAsync(string selector, string expression, object arg = null)
=> ScriptsHelper.ParseEvaluateResult<JsonElement?>(await _channel.EvalOnSelectorAsync(
selector: selector,
script: expression,
arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
public async Task<T> EvalOnSelectorAsync<T>(string selector, string expression, object arg = null)
=> ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvalOnSelectorAsync(
selector: selector,
script: expression,
arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
public async Task<T> EvalOnSelectorAllAsync<T>(string selector, string expression, object arg = null)
=> ScriptsHelper.ParseEvaluateResult<T>(await _channel.EvalOnSelectorAllAsync(
selector: selector,
script: expression,
arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
public Task FocusAsync() => _channel.FocusAsync();
public Task DispatchEventAsync(string type, object eventInit = null)
=> _channel.DispatchEventAsync(
type,
eventInit = ScriptsHelper.SerializedArgument(eventInit));
public Task<string> GetAttributeAsync(string name) => _channel.GetAttributeAsync(name);
public Task<string> InnerHTMLAsync() => _channel.InnerHTMLAsync();
public Task<string> InnerTextAsync() => _channel.InnerTextAsync();
public Task<string> TextContentAsync() => _channel.TextContentAsync();
public Task SelectTextAsync(ElementHandleSelectTextOptions options = default)
=> _channel.SelectTextAsync(options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(string values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(new[] { new SelectOptionValue() { Value = values } }, options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(IElementHandle values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(new[] { values }, options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<string> values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(values.Select(x => new SelectOptionValue() { Value = x }), options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(SelectOptionValue values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(new[] { values }, options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<IElementHandle> values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(values, options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<SelectOptionValue> values, ElementHandleSelectOptionOptions options = default)
=> _channel.SelectOptionAsync(values, options?.NoWaitAfter, options?.Force, options?.Timeout);
public Task CheckAsync(ElementHandleCheckOptions options = default)
=> _channel.CheckAsync(
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
public Task UncheckAsync(ElementHandleUncheckOptions options = default)
=> _channel.UncheckAsync(
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
public Task TapAsync(ElementHandleTapOptions options = default)
=> _channel.TapAsync(
position: options?.Position,
modifiers: options?.Modifiers,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
public Task<bool> IsCheckedAsync() => _channel.IsCheckedAsync();
public Task<bool> IsDisabledAsync() => _channel.IsDisabledAsync();
public Task<bool> IsEditableAsync() => _channel.IsEditableAsync();
public Task<bool> IsEnabledAsync() => _channel.IsEnabledAsync();
public Task<bool> IsHiddenAsync() => _channel.IsHiddenAsync();
public Task<bool> IsVisibleAsync() => _channel.IsVisibleAsync();
public Task<string> InputValueAsync(ElementHandleInputValueOptions options = null)
=> _channel.InputValueAsync(options?.Timeout);
public Task SetCheckedAsync(bool checkedState, ElementHandleSetCheckedOptions options = null)
=> checkedState
? _channel.CheckAsync(
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial)
: _channel.UncheckAsync(
position: options?.Position,
timeout: options?.Timeout,
force: options?.Force,
noWaitAfter: options?.NoWaitAfter,
trial: options?.Trial);
internal static ScreenshotType DetermineScreenshotType(string path)
{
string mimeType = path.MimeType();
return mimeType switch
{
"image/png" => ScreenshotType.Png,
"image/jpeg" => ScreenshotType.Jpeg,
_ => throw new ArgumentException($"path: unsupported mime type \"{mimeType}\""),
};
}
}
}
/*
* MIT License
*
* Copyright (c) Evgeny Nazarchuk.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using Microsoft.Playwright;
using Playwright.Synchronous;
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace Playwright.PageObjectModel;
public partial class ElementModel<TPageModel> : IElementModel, ITypedElementModel<TPageModel>
where TPageModel : PageModel
{
public IPage Page { get; }
public IElementHandle Element { get; }
public TPageModel PageModel { get; }
public ElementModel(TPageModel pageModel,
string selector,
PageWaitForSelectorOptions? waitOptions = null,
PageQuerySelectorOptions? queryOptions = null)
{
this.PageModel = pageModel;
this.PageModel.Page.WaitForSelector(selector, waitOptions);
this.Element = this.PageModel.Page.QuerySelector(selector, queryOptions)!;
this.PageModel = pageModel;
this.Page = this.PageModel.Page;
}
public ElementModel(ElementModel<TPageModel> parentElementModel,
string selector,
ElementHandleWaitForSelectorOptions? waitOptions = null)
{
this.Element = parentElementModel.GetElement(selector, waitOptions);
this.PageModel = parentElementModel.PageModel;
this.Page = this.PageModel.Page;
}
public ElementModel(TPageModel pageModel, IElementHandle element)
{
this.PageModel = pageModel;
this.Element = element;
this.Page = this.PageModel.Page;
}
public ElementModel(ElementModel<TPageModel> parenTElementModel, IElementHandle element)
{
this.PageModel = parenTElementModel.PageModel;
this.Element = element;
this.Page = this.PageModel.Page;
}
public TPageModel UpToPage()
{
return this.PageModel;
}
protected virtual IElementHandle GetElement(string selector, ElementHandleWaitForSelectorOptions? options = null)
{
this.Element.WaitForSelector(selector, options);
var element = this.Element.QuerySelector(selector);
return element!;
}
protected virtual IElementHandle? GetElementOrNull(string selector)
{
var element = this.Element.QuerySelector(selector);
return element;
}
protected virtual IReadOnlyList<IElementHandle> GetElements(string selector, ElementHandleWaitForSelectorOptions? options = null)
{
var elements = this.Element.QuerySelectorAll(selector);
return elements;
}
protected virtual TElementModel GetElementModel<TElementModel>(string selector)
where TElementModel : ITypedElementModel<TPageModel>
{
var blockType = typeof(TElementModel);
var ctorArgs = new[] { typeof(ElementModel<TPageModel>), typeof(string) };
var ctor = blockType.GetConstructor(ctorArgs);
if (ctor is null) throw new ApplicationException("Block Model not found");
var block = ctor.Invoke(new[] { this, (object)selector });
if (block is null) throw new ApplicationException("Block Model not created");
return (TElementModel)block;
}
protected virtual IReadOnlyCollection<TElementModel> GetElementModels<TElementModel>(string selector)
where TElementModel : ITypedElementModel<TPageModel>
{
var elements = this.Element.QuerySelectorAll(selector);
var blocks = new List<TElementModel>();
foreach (var element in elements)
{
var blockType = typeof(TElementModel);
var ctorArgs = new[] { this.GetType(), typeof(string) };
var ctor = blockType.GetConstructor(ctorArgs);
if (ctor is null) throw new ApplicationException("Block Model not found");
var block = ctor.Invoke(new[] { this, (object)selector });
blocks.Add((TElementModel)block);
}
return blocks;
}
protected virtual void Click(string? selector = null, ElementHandleClickOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Click(options);
}
protected virtual TReturnPage Click<TReturnPage>(string? selector = null, ElementHandleClickOptions? options = null)
where TReturnPage : PageModel
{
this.Click(selector, options);
var ctor = typeof(TReturnPage).GetConstructor(new[] { typeof(IPage) });
if (ctor is null) throw new ApplicationException("Page Model not found");
var returnPage = ctor.Invoke(new[] { this.PageModel.Page });
if (returnPage is null) throw new ApplicationException("Page Model not created");
return (TReturnPage)returnPage;
}
protected virtual void DbClick(string? selector = null, ElementHandleDblClickOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.DblClick(options);
}
protected virtual void Hover(string? selector = null, ElementHandleHoverOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Hover(options);
}
protected virtual void ClearInput(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Evaluate("(element) => element.value =''", element);
}
protected virtual void Type(string? selector = null, string value = "", ElementHandleTypeOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Type(value, options);
}
protected virtual void Fill(string? selector = null, string value = "", ElementHandleFillOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Fill(value, options);
}
protected virtual void Check(string? selector = null, ElementHandleCheckOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Check(options);
}
protected virtual void Uncheck(string? selector = null, ElementHandleUncheckOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Uncheck(options);
}
protected virtual void Focus(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Focus();
}
protected virtual void Tap(string? selector = null, ElementHandleTapOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Tap(options);
}
protected virtual void Press(string key, string? selector = null, ElementHandlePressOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Press(key, options);
}
protected virtual void SelectText(string? selector = null, ElementHandleSelectTextOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectText(options);
}
protected virtual void SetChecked(bool checkedState, string? selector = null, ElementHandleSetCheckedOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SetChecked(checkedState);
}
protected virtual void SetInputFiles(string files, string? selector = null, ElementHandleSetInputFilesOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SetInputFiles(files, options);
}
protected virtual void SetInputFiles(FilePayload files, string? selector = null, ElementHandleSetInputFilesOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SetInputFiles(files, options);
}
protected virtual void SetInputFiles(IEnumerable<string> files, string? selector = null, ElementHandleSetInputFilesOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SetInputFiles(files, options);
}
protected virtual void SetInputFiles(IEnumerable<FilePayload> files, string? selector = null, ElementHandleSetInputFilesOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SetInputFiles(files, options);
}
protected virtual void SelectOption(string values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void SelectOption(IElementHandle values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void SelectOption(IEnumerable<string> values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void SelectOption(SelectOptionValue values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void SelectOption(IEnumerable<IElementHandle> values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void SelectOption(IEnumerable<SelectOptionValue> values, string? selector = null, ElementHandleSelectOptionOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.SelectOption(values, options);
}
protected virtual void ScrollIntoViewIfNeeded(string? selector = null, ElementHandleScrollIntoViewIfNeededOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.ScrollIntoViewIfNeeded(options);
}
protected virtual void Screenshot(string? selector = null, ElementHandleScreenshotOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.Screenshot(options);
}
protected virtual string TextContent(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.TextContent() ?? "";
}
protected virtual string InnerText(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.InnerText();
}
protected virtual string InnerHTML(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.InnerHTML();
}
protected virtual string InputValue(string? selector = null, ElementHandleInputValueOptions? options = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.InputValue(options);
}
protected virtual bool IsChecked(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsChecked();
}
protected virtual bool IsDisabled(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsDisabled();
}
protected virtual bool IsEditable(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsEditable();
}
protected virtual bool IsEnabled(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsEnabled();
}
protected virtual bool IsHidden(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsHidden();
}
protected virtual bool IsVisible(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.IsVisible();
}
protected virtual ElementHandleBoundingBoxResult? BoundingBox(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.BoundingBox();
}
protected virtual IFrame? ContentFrame(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.ContentFrame();
}
protected virtual void DispatchEvent(string type, string? selector = null, object? eventInit = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
element.DispatchEvent(type);
}
protected virtual T EvalOnSelector<T>(string selector, string expression, object? arg = null)
{
return this.Element.EvalOnSelector<T>(selector, expression, arg);
}
protected virtual T EvalOnSelectorAll<T>(string selector, string expression, object? arg = null)
{
return this.Element.EvalOnSelectorAll<T>(selector, expression, arg);
}
protected virtual JsonElement? EvalOnSelector(string selector, string expression, object? arg = null)
{
return this.Element.EvalOnSelector(selector, expression, arg);
}
protected string? GetAttributeValue(string name, string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.GetAttribute(name);
}
protected string GetComputedStyle(string name, string? selector = null)
{
var element = selector is null ? this.Element : GetElement(selector);
var value = Element.Evaluate<string>($"e => getComputedStyle(e).{name}", element);
return value;
}
protected virtual IFrame? OwnerFrame(string? selector = null)
{
var element = selector is null ? this.Element : this.GetElement(selector);
return element.OwnerFrame();
}
}