Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions dotnet/src/webdriver/DomMutatedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ namespace OpenQA.Selenium
/// </summary>
public class DomMutatedEventArgs : EventArgs
{
private DomMutationData attributeData;
internal DomMutatedEventArgs(DomMutationData attributeData)
{
AttributeData = attributeData;
}

/// <summary>
/// Gets the data about the attribute being changed.
/// </summary>
public DomMutationData AttributeData
{
get { return this.attributeData; }
internal set { this.attributeData = value; }
}
public DomMutationData AttributeData { get; }
}
}
32 changes: 6 additions & 26 deletions dotnet/src/webdriver/DomMutationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,38 @@ namespace OpenQA.Selenium
/// </summary>
public class DomMutationData
{
private string targetId;
private string attributeName;
private string attributeValue;
private string attributeOriginalValue;

/// <summary>
/// Gets the ID of the element whose value is changing.
/// </summary>
[JsonPropertyName("target")]
[JsonInclude]
public string TargetId
{
get { return this.targetId; }
internal set { this.targetId = value; }
}
public string TargetId { get; internal set; }

/// <summary>
/// Gets the name of the attribute that is changing.
/// </summary>
[JsonPropertyName("name")]
[JsonInclude]
public string AttributeName
{
get { return this.attributeName; }
internal set { this.attributeName = value; }
}
public string AttributeName { get; internal set; }

/// <summary>
/// Gets the value to which the attribute is being changed.
/// </summary>
[JsonPropertyName("value")]
[JsonInclude]
public string AttributeValue
{
get { return this.attributeValue; }
internal set { this.attributeValue = value; }
}
public string AttributeValue { get; internal set; }

/// <summary>
/// Gets the value from which the attribute has been changed.
/// </summary>
[JsonPropertyName("oldValue")]
[JsonInclude]
public string AttributeOriginalValue
{
get { return this.attributeOriginalValue; }
internal set { this.attributeOriginalValue = value; }
}
public string AttributeOriginalValue { get; internal set; }

/// <summary>
/// Stores the element associated with the target ID
/// </summary>
[JsonIgnore]
public IWebElement Element { get; internal set; }

/// <summary>
Expand All @@ -86,7 +66,7 @@ public string AttributeOriginalValue
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return string.Format("target: {0}, name: {1}, value: {2}, originalValue: {3}", this.targetId, this.attributeName, this.attributeValue, this.attributeOriginalValue);
return string.Format("target: {0}, name: {1}, value: {2}, originalValue: {3}", this.TargetId, this.AttributeName, this.AttributeValue, this.AttributeOriginalValue);
}
}
}
19 changes: 12 additions & 7 deletions dotnet/src/webdriver/IJavaScriptEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
Expand All @@ -31,22 +33,22 @@ public interface IJavaScriptEngine : IDisposable
/// <summary>
/// Occurs when a JavaScript callback with a named binding is executed.
/// </summary>
event EventHandler<JavaScriptCallbackExecutedEventArgs> JavaScriptCallbackExecuted;
event EventHandler<JavaScriptCallbackExecutedEventArgs>? JavaScriptCallbackExecuted;

/// <summary>
/// Occurs when an exeception is thrown by JavaScript being executed in the browser.
/// Occurs when an exception is thrown by JavaScript being executed in the browser.
/// </summary>
event EventHandler<JavaScriptExceptionThrownEventArgs> JavaScriptExceptionThrown;
event EventHandler<JavaScriptExceptionThrownEventArgs>? JavaScriptExceptionThrown;

/// <summary>
/// Occurs when methods on the JavaScript console are called.
/// </summary>
event EventHandler<JavaScriptConsoleApiCalledEventArgs> JavaScriptConsoleApiCalled;
event EventHandler<JavaScriptConsoleApiCalledEventArgs>? JavaScriptConsoleApiCalled;

/// <summary>
/// Occurs when a value of an attribute in an element is being changed.
/// </summary>
event EventHandler<DomMutatedEventArgs> DomMutated;
event EventHandler<DomMutatedEventArgs>? DomMutated;

/// <summary>
/// Gets the read-only list of initialization scripts added for this JavaScript engine.
Expand Down Expand Up @@ -87,7 +89,7 @@ public interface IJavaScriptEngine : IDisposable
/// <param name="scriptName">The friendly name by which to refer to this initialization script.</param>
/// <param name="script">The JavaScript to be loaded on every page.</param>
/// <returns>A task containing an <see cref="InitializationScript"/> object representing the script to be loaded on each page.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="scriptName"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="scriptName"/> or <paramref name="script"/> are <see langword="null"/>.</exception>
Task<InitializationScript> AddInitializationScript(string scriptName, string script);

/// <summary>
Expand All @@ -99,7 +101,7 @@ public interface IJavaScriptEngine : IDisposable
Task RemoveInitializationScript(string scriptName);

/// <summary>
/// Asynchronously removes all intialization scripts from being
/// Asynchronously removes all initialization scripts from being
/// loaded on every document load.
/// </summary>
/// <returns>A task that represents the asynchronous operation.</returns>
Expand Down Expand Up @@ -129,13 +131,16 @@ public interface IJavaScriptEngine : IDisposable
/// </summary>
/// <param name="bindingName">The name of the callback that will trigger events when called by JavaScript executing in the browser.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="bindingName"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If A binding with the specified name already exists.</exception>
Task AddScriptCallbackBinding(string bindingName);

/// <summary>
/// Asynchronously removes a binding to a JavaScript callback.
/// </summary>
/// <param name="bindingName">The name of the callback to be removed.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="bindingName"/> is <see langword="null"/>.</exception>
Task RemoveScriptCallbackBinding(string bindingName);

/// <summary>
Expand Down
24 changes: 20 additions & 4 deletions dotnet/src/webdriver/InitializationScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,45 @@
// under the License.
// </copyright>

using System;
using System.Globalization;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// Represents a JavaScript script that is loaded and run on every document load.
/// </summary>
public class InitializationScript
public class InitializationScript : IEquatable<InitializationScript>
{
internal InitializationScript(string scriptId, string scriptName, string scriptSource)
{
this.ScriptId = scriptId ?? throw new ArgumentNullException(nameof(scriptId));
this.ScriptName = scriptName ?? throw new ArgumentNullException(nameof(scriptName));
this.ScriptSource = scriptSource ?? throw new ArgumentNullException(nameof(scriptSource));
}

/// <summary>
/// Gets the internal ID of the initialization script.
/// </summary>
public string ScriptId { get; internal set; }
public string ScriptId { get; }

/// <summary>
/// Gets the friendly name of the initialization script.
/// </summary>
public string ScriptName { get; internal set; }
public string ScriptName { get; }

/// <summary>
/// Gets the JavaScript source of the initialization script.
/// </summary>
public string ScriptSource { get; internal set; }
public string ScriptSource { get; }

/// <inheritdoc />
public bool Equals(InitializationScript? other)
{
return other is not null && this.ScriptId.Equals(other.ScriptId) && this.ScriptName.Equals(other.ScriptName) && this.ScriptSource.Equals(other.ScriptSource);
}

/// <summary>
/// Returns a string that represents the current object.
Expand Down
20 changes: 14 additions & 6 deletions dotnet/src/webdriver/JavaScriptCallbackExecutedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ namespace OpenQA.Selenium
/// </summary>
public class JavaScriptCallbackExecutedEventArgs : EventArgs
{
private string bindingName;
private string payload;

/// <summary>
/// Gets or sets the binding name of the JavaScript callback that was execute.
/// Initializes a new instance of the <see cref="JavaScriptCallbackExecutedEventArgs"/> type.
/// </summary>
public string BindingName { get => bindingName; set => bindingName = value; }
/// <param name="scriptPayload">The payload sent from the JavaScript callback.</param>
/// <param name="bindingName">The binding name of the JavaScript callback that was execute.</param>
public JavaScriptCallbackExecutedEventArgs(string scriptPayload, string bindingName)
{
this.ScriptPayload = scriptPayload;
this.BindingName = bindingName;
}

/// <summary>
/// Gets or sets the payload sent from the JavaScript callback.
/// </summary>
public string ScriptPayload { get => payload; set => payload = value; }
public string ScriptPayload { get; set; }

/// <summary>
/// Gets or sets the binding name of the JavaScript callback that was execute.
/// </summary>
public string BindingName { get; set; }
}
}
23 changes: 16 additions & 7 deletions dotnet/src/webdriver/JavaScriptConsoleApiCalledEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,32 @@ namespace OpenQA.Selenium
/// </summary>
public class JavaScriptConsoleApiCalledEventArgs : EventArgs
{
private string messageContent;
private DateTime messageTimeStamp;
private string messageType;
/// <summary>
/// Initializes a new instance of the <see cref="JavaScriptConsoleApiCalledEventArgs"/> type.
/// </summary>
/// <param name="messageContent">The content of the message written to the JavaScript console.</param>
/// <param name="messageTimeStamp">The time stamp of the message written to the JavaScript console.</param>
/// <param name="messageType">The type of message written to the JavaScript console.</param>
public JavaScriptConsoleApiCalledEventArgs(string messageContent, DateTime messageTimeStamp, string messageType)
{
this.MessageContent = messageContent;
this.MessageTimeStamp = messageTimeStamp;
this.MessageType = messageType;
}

/// <summary>
/// Gets or sets the content of the message written to the JavaScript console
/// Gets or sets the content of the message written to the JavaScript console.
/// </summary>
public string MessageContent { get => messageContent; set => messageContent = value; }
public string MessageContent { get; set; }

/// <summary>
/// Gets or sets the time stamp of the message written to the JavaScript console.
/// </summary>
public DateTime MessageTimeStamp { get => messageTimeStamp; set => messageTimeStamp = value; }
public DateTime MessageTimeStamp { get; set; }

/// <summary>
/// Gets or sets the type of message written to the JavaScript console.
/// </summary>
public string MessageType { get => messageType; set => messageType = value; }
public string MessageType { get; set; }
}
}
Loading