Skip to content

Commit

Permalink
Merge branch 'trunk' into sm_mixed_output
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner authored Jan 20, 2024
2 parents 31eda98 + d035b5d commit 154185c
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 168 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-rbe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
format:
name: Format
if: github.repository_owner == 'seleniumhq'
uses: ./.github/workflows/bazel.yml
with:
name: Check format script run
Expand All @@ -19,6 +20,7 @@ jobs:

test:
name: Test
if: github.repository_owner == 'seleniumhq'
uses: ./.github/workflows/bazel.yml
with:
# TODO: experiment with turning off caches
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
name: "Release Binaries"
runs-on: ubuntu-latest
needs: [macos-stable, linux-stable, windows-stable, macos-debug, linux-debug, windows-debug]
if: github.event_name != 'schedule'
if: github.event_name != 'schedule' && github.repository_owner == 'seleniumhq' && github.ref == 'refs/heads/trunk'
steps:
- name: "Checkout selenium_manager_artifacts"
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/label-commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:

jobs:
comment:
if: github.repository_owner == 'seleniumhq'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:

jobs:
action:
if: github.repository_owner == 'seleniumhq'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/mirror-selenium-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
build:
if: github.repository_owner == 'seleniumhq'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -24,7 +25,7 @@ jobs:
export CHANGES=$(git status -s)
if [ -n "$CHANGES" ]; then
git config --local user.email "[email protected]"
git config --local user.name "Selenium CI Bot"
git config --local user.name "Selenium CI Bot"
git add common/mirror/selenium
git commit -m "Update mirror info (`date`)" -a
echo "::set-output name=commit::true"
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

jobs:
ruby:
if: inputs.language == 'ruby' || github.event_name == 'schedule'
if: (github.repository_owner == 'seleniumhq') && (inputs.language == 'ruby' || github.event_name == 'schedule')
name: Ruby
uses: ./.github/workflows/bazel.yml
strategy:
Expand All @@ -37,8 +37,9 @@ jobs:
bazel run //rb:${{ matrix.gem }}-bump-nightly-version ${{ inputs.version }}
bazel run //rb:${{ matrix.gem }}-release-nightly
java:
if: inputs.language == 'java' || github.event_name == 'schedule'
if: (github.repository_owner == 'seleniumhq') && (inputs.language == 'java' || github.event_name == 'schedule')
name: Java
uses: ./.github/workflows/bazel.yml
with:
Expand All @@ -49,7 +50,7 @@ jobs:
secrets: inherit

grid:
if: inputs.language == 'grid' || github.event_name == 'schedule'
if: (github.repository_owner == 'seleniumhq') && (inputs.language == 'grid' || github.event_name == 'schedule')
name: Grid
uses: ./.github/workflows/bazel.yml
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
stale:
if: github.repository_owner == 'seleniumhq'
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
Expand Down
12 changes: 0 additions & 12 deletions dotnet/src/webdriver/Chrome/ChromeDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ public static ChromeDriverService CreateDefaultService()
return new ChromeDriverService(null, null, PortUtilities.FindFreePort());
}

/// <summary>
/// Creates a default instance of the ChromeDriverService.
/// </summary>
/// /// <param name="options">Browser options used to find the correct ChromeDriver binary.</param>
/// <returns>A ChromeDriverService that implements default settings.</returns>
[Obsolete("CreateDefaultService() now evaluates options in Driver constructor")]
public static ChromeDriverService CreateDefaultService(ChromeOptions options)
{
string fullServicePath = DriverFinder.FullPath(options);
return CreateDefaultService(Path.GetDirectoryName(fullServicePath), Path.GetFileName(fullServicePath));
}

/// <summary>
/// Creates a default instance of the ChromeDriverService using a specified path to the ChromeDriver executable.
/// </summary>
Expand Down
21 changes: 0 additions & 21 deletions dotnet/src/webdriver/Chromium/ChromiumOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,6 @@ public ChromiumAndroidOptions AndroidOptions
set { this.androidOptions = value; }
}

/// <summary>
/// Gets or sets a value indicating whether the <see cref="ChromiumDriver"/> instance
/// should use the legacy OSS protocol dialect or a dialect compliant with the W3C
/// WebDriver Specification.
/// </summary>
[Obsolete("Spec Compliant Protocol is the only supported protocol")]
public bool UseSpecCompliantProtocol
{
get { return this.useSpecCompliantProtocol; }
set
{
if (!value)
{
throw new ArgumentException("Only the spec compliant protocol is supported, " +
"Please update to W3C Syntax: " +
"https://www.selenium.dev/blog/2022/legacy-protocol-support/");
}
this.useSpecCompliantProtocol = true;
}
}

/// <summary>
/// Adds a single argument to the list of arguments to be appended to the browser executable command line.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/DriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ protected virtual bool IsInitialized
}
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
{
logger.Trace(ex.ToString());
if (logger.IsEnabled(LogEventLevel.Trace))
{
logger.Trace(ex.ToString());
}
}

return isInitialized;
Expand Down
12 changes: 0 additions & 12 deletions dotnet/src/webdriver/Edge/EdgeDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ public static EdgeDriverService CreateDefaultService()
return new EdgeDriverService(null, null, PortUtilities.FindFreePort());
}

/// <summary>
/// Creates a default instance of the EdgeDriverService.
/// </summary>
/// <param name="options">Browser options used to find the correct MSEdgeDriver binary.</param>
/// <returns>A EdgeDriverService that implements default settings.</returns>
[Obsolete("CreateDefaultService() now evaluates options in Driver constructor")]
public static EdgeDriverService CreateDefaultService(EdgeOptions options)
{
string fullServicePath = DriverFinder.FullPath(options);
return CreateDefaultService(Path.GetDirectoryName(fullServicePath), Path.GetFileName(fullServicePath));
}

/// <summary>
/// Creates a default instance of the EdgeDriverService using a specified path to the EdgeDriver executable.
/// </summary>
Expand Down
12 changes: 0 additions & 12 deletions dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,6 @@ public static FirefoxDriverService CreateDefaultService()
}


/// <summary>
/// Creates a default instance of the FirefoxDriverService.
/// </summary>
/// <param name="options">Browser options used to find the correct GeckoDriver binary.</param>
/// <returns>A FirefoxDriverService that implements default settings.</returns>
[Obsolete("CreateDefaultService() now evaluates options in Driver constructor")]
public static FirefoxDriverService CreateDefaultService(FirefoxOptions options)
{
string fullServicePath = DriverFinder.FullPath(options);
return CreateDefaultService(Path.GetDirectoryName(fullServicePath), Path.GetFileName(fullServicePath));
}

/// <summary>
/// Creates a default instance of the FirefoxDriverService using a specified path to the Firefox driver executable.
/// </summary>
Expand Down
12 changes: 0 additions & 12 deletions dotnet/src/webdriver/IE/InternetExplorerDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,6 @@ public static InternetExplorerDriverService CreateDefaultService()
return new InternetExplorerDriverService(null, null, PortUtilities.FindFreePort());
}

/// <summary>
/// Creates a default instance of the InternetExplorerDriverService.
/// </summary>
/// <param name="options">Browser options used to find the correct IEDriver binary.</param>
/// <returns>A InternetExplorerDriverService that implements default settings.</returns>
[Obsolete("CreateDefaultService() now evaluates options in Driver constructor")]
public static InternetExplorerDriverService CreateDefaultService(InternetExplorerOptions options)
{
string fullServicePath = DriverFinder.FullPath(options);
return CreateDefaultService(Path.GetDirectoryName(fullServicePath), Path.GetFileName(fullServicePath));
}

/// <summary>
/// Creates a default instance of the InternetExplorerDriverService using a specified path to the IEDriverServer executable.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/Internal/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public static void DeleteDirectory(string directoryToDelete)

if (Directory.Exists(directoryToDelete))
{
logger.Trace($"Unable to delete directory '{directoryToDelete}'");
if (logger.IsEnabled(LogEventLevel.Trace))
{
logger.Trace($"Unable to delete directory '{directoryToDelete}'");
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions dotnet/src/webdriver/Internal/Logging/ILogContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public interface ILogContext : IDisposable
/// <returns>An instance of <see cref="ILogger"/> for the specified type.</returns>
internal ILogger GetLogger(Type type);

/// <summary>
/// Checks whether logs emitting is enabled for a logger and a log event level.
/// </summary>
/// <param name="logger">The specified logger instance to be checked.</param>
/// <param name="level">The specified log event level to be checked.</param>
/// <returns><c>true</c> if log messages emmiting is enabled for the specified logger and log event level, otherwise <c>false</c>.</returns>
internal bool IsEnabled(ILogger logger, LogEventLevel level);

/// <summary>
/// Emits a log message using the specified logger, log level, and message.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions dotnet/src/webdriver/Internal/Logging/ILogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,12 @@ internal interface ILogger
/// Gets the type of the logger issuer.
/// </summary>
Type Issuer { get; }

/// <summary>
/// Checks whether logs emitting is enabled for this logger and a log event level.
/// </summary>
/// <param name="level">The specified log event level to be checked.</param>
/// <returns><c>true</c> if log messages emmiting is enabled for the specified log event level, otherwise <c>false</c>.</returns>
bool IsEnabled(LogEventLevel level);
}
}
7 changes: 6 additions & 1 deletion dotnet/src/webdriver/Internal/Logging/LogContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ public ILogger GetLogger(Type type)
return _loggers.GetOrAdd(type, _ => new Logger(type, _level));
}

public bool IsEnabled(ILogger logger, LogEventLevel level)
{
return Handlers != null && level >= _level && level >= logger.Level;
}

public void EmitMessage(ILogger logger, LogEventLevel level, string message)
{
if (Handlers != null && level >= _level && level >= GetLogger(logger.Issuer).Level)
if (IsEnabled(logger, level))
{
var logEvent = new LogEvent(logger.Issuer, DateTimeOffset.Now, level, message);

Expand Down
5 changes: 5 additions & 0 deletions dotnet/src/webdriver/Internal/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public void Error(string message)
LogMessage(LogEventLevel.Error, message);
}

public bool IsEnabled(LogEventLevel level)
{
return Log.CurrentContext.IsEnabled(this, level);
}

private void LogMessage(LogEventLevel level, string message)
{
Log.CurrentContext.EmitMessage(this, level, message);
Expand Down
22 changes: 16 additions & 6 deletions dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Internal.Logging;
Expand Down Expand Up @@ -166,7 +164,10 @@ public virtual Response Execute(Command commandToExecute)
throw new ArgumentNullException(nameof(commandToExecute), "commandToExecute cannot be null");
}

_logger.Debug($"Executing command: {commandToExecute}");
if (_logger.IsEnabled(LogEventLevel.Debug))
{
_logger.Debug($"Executing command: {commandToExecute}");
}

HttpCommandInfo info = this.commandInfoRepository.GetCommandInfo<HttpCommandInfo>(commandToExecute.Name);
if (info == null)
Expand Down Expand Up @@ -198,7 +199,10 @@ public virtual Response Execute(Command commandToExecute)

Response toReturn = this.CreateResponse(responseInfo);

_logger.Debug($"Response: {toReturn}");
if (_logger.IsEnabled(LogEventLevel.Debug))
{
_logger.Debug($"Response: {toReturn}");
}

return toReturn;
}
Expand Down Expand Up @@ -279,11 +283,17 @@ private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo
requestMessage.Content.Headers.ContentType = contentTypeHeader;
}

_logger.Trace($">> {requestMessage}");
if (_logger.IsEnabled(LogEventLevel.Trace))
{
_logger.Trace($">> {requestMessage}");
}

using (HttpResponseMessage responseMessage = await this.client.SendAsync(requestMessage).ConfigureAwait(false))
{
_logger.Trace($"<< {responseMessage}");
if (_logger.IsEnabled(LogEventLevel.Trace))
{
_logger.Trace($"<< {responseMessage}");
}

HttpResponseInfo httpResponseInfo = new HttpResponseInfo();
httpResponseInfo.Body = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
Expand Down
38 changes: 0 additions & 38 deletions dotnet/src/webdriver/Remote/RemoteWebElement.cs

This file was deleted.

Loading

0 comments on commit 154185c

Please sign in to comment.