Skip to content

Commit 9e53690

Browse files
authored
[dotnet] allow RemoteWebDriver to access Selenium logs (#10671)
fixes #8229
1 parent d685665 commit 9e53690

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

dotnet/src/webdriver/Logs.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using System;
1920
using System.Collections.Generic;
2021
using System.Collections.ObjectModel;
2122

@@ -27,7 +28,6 @@ namespace OpenQA.Selenium
2728
public class Logs : ILogs
2829
{
2930
private WebDriver driver;
30-
private bool isLogSupported = false;
3131

3232
/// <summary>
3333
/// Initializes a new instance of the <see cref="RemoteLogs"/> class.
@@ -36,7 +36,6 @@ public class Logs : ILogs
3636
public Logs(WebDriver driver)
3737
{
3838
this.driver = driver;
39-
this.isLogSupported = (this.driver as ISupportsLogs) != null;
4039
}
4140

4241
/// <summary>
@@ -47,7 +46,7 @@ public ReadOnlyCollection<string> AvailableLogTypes
4746
get
4847
{
4948
List<string> availableLogTypes = new List<string>();
50-
if (this.isLogSupported)
49+
try
5150
{
5251
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAvailableLogTypes, null);
5352
object[] responseValue = commandResponse.Value as object[];
@@ -59,6 +58,10 @@ public ReadOnlyCollection<string> AvailableLogTypes
5958
}
6059
}
6160
}
61+
catch (NotImplementedException)
62+
{
63+
// Swallow for backwards compatibility
64+
}
6265

6366
return availableLogTypes.AsReadOnly();
6467
}
@@ -73,7 +76,7 @@ public ReadOnlyCollection<string> AvailableLogTypes
7376
public ReadOnlyCollection<LogEntry> GetLog(string logKind)
7477
{
7578
List<LogEntry> entries = new List<LogEntry>();
76-
if (this.isLogSupported)
79+
try
7780
{
7881
Dictionary<string, object> parameters = new Dictionary<string, object>();
7982
parameters.Add("type", logKind);
@@ -92,6 +95,10 @@ public ReadOnlyCollection<LogEntry> GetLog(string logKind)
9295
}
9396
}
9497
}
98+
catch (NotImplementedException)
99+
{
100+
// Swallow for backwards compatibility
101+
}
95102

96103
return entries.AsReadOnly();
97104
}

0 commit comments

Comments
 (0)