Skip to content

Commit

Permalink
Merge branch 'trunk' into selenium_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 authored Dec 8, 2024
2 parents c913273 + cc58a4e commit 78975b2
Show file tree
Hide file tree
Showing 91 changed files with 1,206 additions and 1,219 deletions.
50 changes: 25 additions & 25 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def pin_browsers():

http_archive(
name = "linux_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/linux-x86_64/en-US/firefox-132.0.2.tar.bz2",
sha256 = "777d47f8b8710ab450582dc0dc0cdf8f43c2291249b3eaf740ee28ee34cda139",
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0/linux-x86_64/en-US/firefox-133.0.tar.bz2",
sha256 = "63cb097174d429043ad128341358d14cdb5d4c9d05d035d9e3094634ceaf22c2",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -33,8 +33,8 @@ js_library(

dmg_archive(
name = "mac_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/mac/en-US/Firefox%20132.0.2.dmg",
sha256 = "233251c46eb4964868d815a9233cab855ac6160736310771a67af93a9b78224d",
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0/mac/en-US/Firefox%20133.0.dmg",
sha256 = "02c76e21d64f21d4e45b1205717ccd0736a75f2a50b01c74b25b17e374447a76",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -50,8 +50,8 @@ js_library(

http_archive(
name = "linux_beta_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/linux-x86_64/en-US/firefox-133.0b9.tar.bz2",
sha256 = "5c9f79912bfbf892d2b676973a26ffc078ee9b8fd9b791bfa856db030e657750",
url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b5/linux-x86_64/en-US/firefox-134.0b5.tar.bz2",
sha256 = "9688f50d2bba71c7781e7f46100e97223d469d37197cf99511a2b2e27efd50a2",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -72,8 +72,8 @@ js_library(

dmg_archive(
name = "mac_beta_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/mac/en-US/Firefox%20133.0b9.dmg",
sha256 = "0eb0fabe9216dc80c2ca403dd2eba935d71f2bdc1dea1d1cc37f03666ef094d1",
url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b5/mac/en-US/Firefox%20134.0b5.dmg",
sha256 = "5c6d02d149637e963c55c741ebed98a8dacfa93c90e99065981bbdd9d511a0f1",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -123,10 +123,10 @@ js_library(

pkg_archive(
name = "mac_edge",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/08b226c9-fbe8-43c0-94fe-ed9c3eeb8f59/MicrosoftEdge-131.0.2903.51.pkg",
sha256 = "5bc1eab86bb315aa9f2cd2b7d9afe072df35280f6e6d1a9ca9c108d95bda8acd",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/a310bc51-4dc2-4780-9677-41f3ecf37e31/MicrosoftEdge-131.0.2903.86.pkg",
sha256 = "77dc0bf6d465815d3414a1b52d506323619c9debb12f9feb85ec4ad2c7e58585",
move = {
"MicrosoftEdge-131.0.2903.51.pkg/Payload/Microsoft Edge.app": "Edge.app",
"MicrosoftEdge-131.0.2903.86.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -143,8 +143,8 @@ js_library(

deb_archive(
name = "linux_edge",
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.51-1_amd64.deb",
sha256 = "8aad12c97bcae417ff9cc4251b75211eeda7f1513312dc57b2f744e824e028c0",
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.86-1_amd64.deb",
sha256 = "4c7844e51ffefbf5a595f3d93e633481c6081f0fd954d15cc08066ea23ddacf3",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -165,8 +165,8 @@ js_library(

http_archive(
name = "linux_edgedriver",
url = "https://msedgedriver.azureedge.net/131.0.2903.52/edgedriver_linux64.zip",
sha256 = "ddbeda7cec5ed16b96c3cf0f6759de30e4f3726da9da31bfba1371ccd8fcfd14",
url = "https://msedgedriver.azureedge.net/131.0.2903.84/edgedriver_linux64.zip",
sha256 = "13b8024056a2ae72dfc45907213212756ffaf52567fa2b367acadd20badfb4bb",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -182,8 +182,8 @@ js_library(

http_archive(
name = "mac_edgedriver",
url = "https://msedgedriver.azureedge.net/131.0.2903.56/edgedriver_mac64.zip",
sha256 = "4f4d1d5b45849677f8d8e706f7b5ca9ebb99f40ed3b4ee203c2535a3429e0d5b",
url = "https://msedgedriver.azureedge.net/131.0.2903.84/edgedriver_mac64.zip",
sha256 = "288c7b38d24a0650ca60e9e2a231c0c71976adc37be9e11e777e0596c40b3878",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -199,8 +199,8 @@ js_library(

http_archive(
name = "linux_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chrome-linux64.zip",
sha256 = "3a6d928b0002ec012a53b6bb65dcaf95add008adc223c961d566d824982a767e",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/linux64/chrome-linux64.zip",
sha256 = "5ed0d25537b964cdf826224165a80d125ae67bbb980065c2f1e665dae6686904",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -221,8 +221,8 @@ js_library(

http_archive(
name = "mac_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chrome-mac-x64.zip",
sha256 = "e26a606e2a3da403c6e1e93617a7b51ee010706614eb88de5b16470276e0896b",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/mac-x64/chrome-mac-x64.zip",
sha256 = "a9ab895b3ab102973f224f35bef6f0336b690f03cc5fbb73110bf448fe30ce70",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -243,8 +243,8 @@ js_library(

http_archive(
name = "linux_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chromedriver-linux64.zip",
sha256 = "33910b16568feabd2b50a26a2c4456d154c760d6e28347427f99c025661a4f3e",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/linux64/chromedriver-linux64.zip",
sha256 = "bb0c5ee6594453258b328b838adc194ed0df000f2a6e5ead306b637a995e387b",
strip_prefix = "chromedriver-linux64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -261,8 +261,8 @@ js_library(

http_archive(
name = "mac_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chromedriver-mac-x64.zip",
sha256 = "ee194eba1d52dea61dfbf08b05a2ce139660e9c7d20d15024c3a0757ac4a5fcb",
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/mac-x64/chromedriver-mac-x64.zip",
sha256 = "9fa91a7b7e969cbd6edb089e14b8db2189353519640dcc84c067369918bfb04f",
strip_prefix = "chromedriver-mac-x64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/ILogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
// under the License.
// </copyright>

using System;
using System.Collections.ObjectModel;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
Expand All @@ -37,6 +40,7 @@ public interface ILogs
/// <param name="logKind">The log for which to retrieve the log entries.
/// Log types can be found in the <see cref="LogType"/> class.</param>
/// <returns>The list of <see cref="LogEntry"/> objects for the specified log.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="logKind"/> is <see langword="null"/>.</exception>
ReadOnlyCollection<LogEntry> GetLog(string logKind);
}
}
1 change: 1 addition & 0 deletions dotnet/src/webdriver/Interactions/ActionSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public int Count
/// Gets the input device for this Action sequence.
/// </summary>
[Obsolete("This property has been renamed to InputDevice and will be removed in a future version")]
[CLSCompliant(false)]
public InputDevice inputDevice => InputDevice;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/Interactions/Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private InputDevice FindDeviceById(string name)

if (id == name)
{
return sequence.inputDevice;
return sequence.InputDevice;
}
}

Expand Down
47 changes: 19 additions & 28 deletions dotnet/src/webdriver/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
using System.Collections.Generic;
using System.Globalization;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// Represents an entry in a log from a driver instance.
/// </summary>
public class LogEntry
{
private LogLevel level = LogLevel.All;
private DateTime timestamp = DateTime.MinValue;
private string message = string.Empty;

/// <summary>
/// Initializes a new instance of the <see cref="LogEntry"/> class.
Expand All @@ -42,34 +41,27 @@ private LogEntry()
/// <summary>
/// Gets the timestamp value of the log entry.
/// </summary>
public DateTime Timestamp
{
get { return this.timestamp; }
}
public DateTime Timestamp { get; private set; } = DateTime.MinValue;

/// <summary>
/// Gets the logging level of the log entry.
/// </summary>
public LogLevel Level
{
get { return this.level; }
}
public LogLevel Level { get; private set; } = LogLevel.All;

/// <summary>
/// Gets the message of the log entry.
/// </summary>
public string Message
{
get { return this.message; }
}
public string Message { get; private set; } = string.Empty;

private static readonly DateTime UnixEpoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

/// <summary>
/// Returns a string that represents the current <see cref="LogEntry"/>.
/// </summary>
/// <returns>A string that represents the current <see cref="LogEntry"/>.</returns>
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.timestamp, this.level, this.message);
return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.Timestamp, this.Level, this.Message);
}

/// <summary>
Expand All @@ -78,32 +70,31 @@ public override string ToString()
/// <param name="entryDictionary">The <see cref="Dictionary{TKey, TValue}"/> from
/// which to create the <see cref="LogEntry"/>.</param>
/// <returns>A <see cref="LogEntry"/> with the values in the dictionary.</returns>
internal static LogEntry FromDictionary(Dictionary<string, object> entryDictionary)
internal static LogEntry FromDictionary(Dictionary<string, object?> entryDictionary)
{
LogEntry entry = new LogEntry();
if (entryDictionary.ContainsKey("message"))
if (entryDictionary.TryGetValue("message", out object? message))
{
entry.message = entryDictionary["message"].ToString();
entry.Message = message?.ToString() ?? string.Empty;
}

if (entryDictionary.ContainsKey("timestamp"))
if (entryDictionary.TryGetValue("timestamp", out object? timestamp))
{
DateTime zeroDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
double timestampValue = Convert.ToDouble(entryDictionary["timestamp"], CultureInfo.InvariantCulture);
entry.timestamp = zeroDate.AddMilliseconds(timestampValue);
double timestampValue = Convert.ToDouble(timestamp, CultureInfo.InvariantCulture);
entry.Timestamp = UnixEpoch.AddMilliseconds(timestampValue);
}

if (entryDictionary.ContainsKey("level"))
if (entryDictionary.TryGetValue("level", out object? level))
{
string levelValue = entryDictionary["level"].ToString();
try
if (Enum.TryParse(level?.ToString(), ignoreCase: true, out LogLevel result))
{
entry.level = (LogLevel)Enum.Parse(typeof(LogLevel), levelValue, true);
entry.Level = result;
}
catch (ArgumentException)
else
{
// If the requested log level string is not a valid log level,
// ignore it and use LogLevel.All.
entry.Level = LogLevel.All;
}
}

Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/LogLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// under the License.
// </copyright>

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
Expand Down
26 changes: 16 additions & 10 deletions dotnet/src/webdriver/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// Provides a mechanism for examining logs for the driver during the test.
/// </summary>
public class Logs : ILogs
{
private WebDriver driver;
private readonly WebDriver driver;

/// <summary>
/// Initializes a new instance of the <see cref="Logs"/> class.
/// </summary>
/// <param name="driver">Instance of the driver currently in use</param>
/// <exception cref="ArgumentNullException">If <paramref name="driver"/> is <see langword="null"/>.</exception>
public Logs(WebDriver driver)
{
this.driver = driver;
this.driver = driver ?? throw new ArgumentNullException(nameof(driver));
}

/// <summary>
Expand All @@ -50,12 +53,11 @@ public ReadOnlyCollection<string> AvailableLogTypes
try
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAvailableLogTypes, null);
object[] responseValue = commandResponse.Value as object[];
if (responseValue != null)
if (commandResponse.Value is object[] responseValue)
{
foreach (object logKind in responseValue)
{
availableLogTypes.Add(logKind.ToString());
availableLogTypes.Add(logKind.ToString()!);
}
}
}
Expand All @@ -74,21 +76,25 @@ public ReadOnlyCollection<string> AvailableLogTypes
/// <param name="logKind">The log for which to retrieve the log entries.
/// Log types can be found in the <see cref="LogType"/> class.</param>
/// <returns>The list of <see cref="LogEntry"/> objects for the specified log.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="logKind"/> is <see langword="null"/>.</exception>
public ReadOnlyCollection<LogEntry> GetLog(string logKind)
{
if (logKind is null)
{
throw new ArgumentNullException(nameof(logKind));
}

List<LogEntry> entries = new List<LogEntry>();

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);

object[] responseValue = commandResponse.Value as object[];
if (responseValue != null)
if (commandResponse.Value is object?[] responseValue)
{
foreach (object rawEntry in responseValue)
foreach (object? rawEntry in responseValue)
{
Dictionary<string, object> entryDictionary = rawEntry as Dictionary<string, object>;
if (entryDictionary != null)
if (rawEntry is Dictionary<string, object?> entryDictionary)
{
entries.Add(LogEntry.FromDictionary(entryDictionary));
}
Expand Down
Loading

0 comments on commit 78975b2

Please sign in to comment.