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 11, 2024
2 parents 6d6381a + 28e9a3a commit 759e0d3
Show file tree
Hide file tree
Showing 133 changed files with 6,531 additions and 7,050 deletions.
5 changes: 1 addition & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ namespace :py do
nightly = ".#{Time.now.strftime('%Y%m%d%H%M')}"
new_version = updated_version(old_version, arguments[:version], nightly)

['py/setup.py',
'py/pyproject.toml',
['py/pyproject.toml',
'py/BUILD.bazel',
'py/selenium/__init__.py',
'py/selenium/webdriver/__init__.py',
Expand Down Expand Up @@ -1048,7 +1047,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/selenium/__init__.py',
'py/BUILD.bazel',
'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/Gemfile.lock'])

Expand Down Expand Up @@ -1110,7 +1108,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/BUILD.bazel',
'py/CHANGES',
'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/CHANGES',
'rb/Gemfile.lock',
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ rules_closure_toolchains()

http_archive(
name = "rules_rust",
integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
integrity = "sha256-eEXiHXSGUH6qD1bdI5KXZ/B04m0wIUeoyM7pmujzbbQ=",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.55.5/rules_rust-0.55.5.tar.gz"],
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
Expand Down
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
119 changes: 58 additions & 61 deletions dotnet/src/webdriver/CookieJar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,128 +21,125 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// Defines an interface allowing the user to manipulate cookies on the current page.
/// </summary>
internal class CookieJar : ICookieJar
internal sealed class CookieJar(WebDriver driver) : ICookieJar
{
private WebDriver driver;

/// <summary>
/// Initializes a new instance of the <see cref="CookieJar"/> class.
/// </summary>
/// <param name="driver">The driver that is currently in use</param>
public CookieJar(WebDriver driver)
{
this.driver = driver;
}

/// <summary>
/// Gets all cookies defined for the current page.
/// </summary>
public ReadOnlyCollection<Cookie> AllCookies
{
get { return this.GetAllCookies(); }
get
{
Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary<string, object>());

try
{
List<Cookie> toReturn = new List<Cookie>();
if (response.Value is object?[] cookies)
{
foreach (object? rawCookie in cookies)
{
if (rawCookie != null)
{
Cookie newCookie = Cookie.FromDictionary((Dictionary<string, object?>)rawCookie);
toReturn.Add(newCookie);
}
}
}

return new ReadOnlyCollection<Cookie>(toReturn);
}
catch (Exception e)
{
throw new WebDriverException("Unexpected problem getting cookies", e);
}
}
}

/// <summary>
/// Method for creating a cookie in the browser
/// </summary>
/// <param name="cookie"><see cref="Cookie"/> that represents a cookie in the browser</param>
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
public void AddCookie(Cookie cookie)
{
if (cookie is null)
{
throw new ArgumentNullException(nameof(cookie));
}

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("cookie", cookie);
this.driver.InternalExecute(DriverCommand.AddCookie, parameters);
driver.InternalExecute(DriverCommand.AddCookie, parameters);
}

/// <summary>
/// Delete the cookie by passing in the name of the cookie
/// </summary>
/// <param name="name">The name of the cookie that is in the browser</param>
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
public void DeleteCookieNamed(string name)
{
if (name is null)
{
throw new ArgumentNullException(nameof(name));
}

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("name", name);
this.driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
}

/// <summary>
/// Delete a cookie in the browser by passing in a copy of a cookie
/// </summary>
/// <param name="cookie">An object that represents a copy of the cookie that needs to be deleted</param>
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
public void DeleteCookie(Cookie cookie)
{
if (cookie != null)
if (cookie is null)
{
this.DeleteCookieNamed(cookie.Name);
throw new ArgumentNullException(nameof(cookie));
}

this.DeleteCookieNamed(cookie.Name);
}

/// <summary>
/// Delete All Cookies that are present in the browser
/// </summary>
public void DeleteAllCookies()
{
this.driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
}

/// <summary>
/// Method for returning a getting a cookie by name
/// </summary>
/// <param name="name">name of the cookie that needs to be returned</param>
/// <returns>A Cookie from the name</returns>
public Cookie GetCookieNamed(string name)
/// <returns>A Cookie from the name; or <see langword="null"/> if not found.</returns>
public Cookie? GetCookieNamed(string name)
{
Cookie cookieToReturn = null;
if (name != null)
if (name is null)
{
ReadOnlyCollection<Cookie> allCookies = this.AllCookies;
foreach (Cookie currentCookie in allCookies)
{
if (name.Equals(currentCookie.Name))
{
cookieToReturn = currentCookie;
break;
}
}
throw new ArgumentNullException(nameof(name));
}

return cookieToReturn;
}

/// <summary>
/// Method for getting a Collection of Cookies that are present in the browser
/// </summary>
/// <returns>ReadOnlyCollection of Cookies in the browser</returns>
private ReadOnlyCollection<Cookie> GetAllCookies()
{
List<Cookie> toReturn = new List<Cookie>();
object returned = this.driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary<string, object>()).Value;

try
foreach (Cookie currentCookie in this.AllCookies)
{
object[] cookies = returned as object[];
if (cookies != null)
if (name.Equals(currentCookie.Name))
{
foreach (object rawCookie in cookies)
{
Dictionary<string, object> cookieDictionary = rawCookie as Dictionary<string, object>;
if (rawCookie != null)
{
toReturn.Add(Cookie.FromDictionary(cookieDictionary));
}
}
return currentCookie;
}

return new ReadOnlyCollection<Cookie>(toReturn);
}
catch (Exception e)
{
throw new WebDriverException("Unexpected problem getting cookies", e);
}

return null;
}
}
}
Loading

0 comments on commit 759e0d3

Please sign in to comment.