@@ -17,6 +17,8 @@ namespace CSF.Screenplay.Selenium
1717 /// <seealso cref="IHasQuirks"/>
1818 public static class BrowserQuirks
1919 {
20+ const string chrome = "chrome" , firefox = "firefox" , safari = "safari" , edge = "edge" ;
21+
2022 /// <summary>
2123 /// Gets the name of a browser quirk, for browsers which cannot set the value of an <c><input type="date"></c> using the
2224 /// "Send Keys" technique.
@@ -80,7 +82,7 @@ public static class BrowserQuirks
8082 public static readonly string NeedsJavaScriptToGetShadowRoot = "NeedsJavaScriptToGetShadowRoot" ;
8183
8284 /// <summary>
83- /// Gets the name of a browser quirk, for browser which cannot get a Shadow Root node at all.
85+ /// Gets the name of a browser quirk, for browsers which cannot get a Shadow Root node at all.
8486 /// </summary>
8587 /// <remarks>
8688 /// <para>
@@ -90,6 +92,39 @@ public static class BrowserQuirks
9092 /// </remarks>
9193 public static readonly string CannotGetShadowRoot = "CannotGetShadowRoot" ;
9294
95+ /// <summary>
96+ /// Gets the name of a browser quirk, for browsers which have native support for reading the console logs.
97+ /// </summary>
98+ /// <remarks>
99+ /// <para>
100+ /// Browsers with this quirk can read the console logs via a technique such as:
101+ /// </para>
102+ /// <code>
103+ /// var logs = driver.Manage().Logs.GetLog(LogType.Browser);
104+ /// </code>
105+ /// <para>
106+ /// The log levels recorded depend upon the manner in which the WebDriver is configured.
107+ /// If using the <see cref="Extensions.WebDriver.WebDriverFactory"/>, this may be controlled by
108+ /// the <see cref="Extensions.WebDriver.Factories.WebDriverCreationOptions.BrowserLogLevel"/> property of the configuration.
109+ /// Otherwise, use <see cref="OpenQA.Selenium.DriverOptions.SetLoggingPreference(string, OpenQA.Selenium.LogLevel)"/> to configure
110+ /// logging.
111+ /// </para>
112+ /// </remarks>
113+ public static readonly string HasNativeLogsSupport = "HasNativeLogsSupport" ;
114+
115+ /// <summary>
116+ /// Gets the name of a browser quirk, for browsers which can read browser logs using a Javascript-based workaround.
117+ /// </summary>
118+ /// <remarks>
119+ /// <para>
120+ /// Browsers with this quirk should prefer using the techniques provided by <see cref="HasNativeLogsSupport"/> if they also support them.
121+ /// The use of a Javascript workaround is imperfect and can miss log messages, as described in the documentation for <see cref="GetLogsWithJavaScript"/>.
122+ /// </para>
123+ /// </remarks>
124+ /// <seealso cref="Scripts.CaptureLogs"/>
125+ /// <seealso cref="Scripts.GetLogs"/>
126+ public static readonly string CanGetLogsWithJavascriptWorkaround = "CanGetLogsWithJavascriptWorkaround" ;
127+
93128 /// <summary>
94129 /// Gets hard-coded information about known browser quirks.
95130 /// </summary>
@@ -113,8 +148,8 @@ public static QuirksData GetQuirksData()
113148 {
114149 AffectedBrowsers = new HashSet < BrowserInfo >
115150 {
116- new BrowserInfo { Name = " firefox" } ,
117- new BrowserInfo { Name = " safari" } ,
151+ new BrowserInfo { Name = firefox } ,
152+ new BrowserInfo { Name = safari } ,
118153 }
119154 }
120155 } ,
@@ -124,7 +159,7 @@ public static QuirksData GetQuirksData()
124159 {
125160 AffectedBrowsers = new HashSet < BrowserInfo >
126161 {
127- new BrowserInfo { Name = " safari" } ,
162+ new BrowserInfo { Name = safari } ,
128163 }
129164 }
130165 } ,
@@ -134,10 +169,9 @@ public static QuirksData GetQuirksData()
134169 {
135170 AffectedBrowsers = new HashSet < BrowserInfo >
136171 {
137- new BrowserInfo { Name = "safari" } ,
138- // There is no Chrome 95.1.0.0 but this covers any 95.0.x
139- // The additional trailing zeroes are to work around https://github.com/csf-dev/CSF.Extensions.WebDriver/issues/56
140- new BrowserInfo { Name = "chrome" , MaxVersion = "95.1.0.0" } ,
172+ new BrowserInfo { Name = safari } ,
173+ // There is no Chrome 95.1 but this covers any 95.0.x
174+ new BrowserInfo { Name = chrome , MaxVersion = "95.1" } ,
141175 }
142176 }
143177 } ,
@@ -148,7 +182,30 @@ public static QuirksData GetQuirksData()
148182 AffectedBrowsers = new HashSet < BrowserInfo >
149183 {
150184 // There is no Firefox 112.1 but this covers any 112.0.x
151- new BrowserInfo { Name = "firefox" , MaxVersion = "112.1" }
185+ new BrowserInfo { Name = firefox , MaxVersion = "112.1" } ,
186+ }
187+ }
188+ } ,
189+ {
190+ HasNativeLogsSupport ,
191+ new BrowserInfoCollection
192+ {
193+ AffectedBrowsers = new HashSet < BrowserInfo >
194+ {
195+ new BrowserInfo { Name = chrome } ,
196+ new BrowserInfo { Name = edge } ,
197+ }
198+ }
199+ } ,
200+ {
201+ CanGetLogsWithJavascriptWorkaround ,
202+ new BrowserInfoCollection
203+ {
204+ AffectedBrowsers = new HashSet < BrowserInfo >
205+ {
206+ new BrowserInfo { Name = firefox } ,
207+ new BrowserInfo { Name = chrome } ,
208+ new BrowserInfo { Name = edge } ,
152209 }
153210 }
154211 }
0 commit comments