55using Microsoft . VisualStudio . TestTools . UnitTesting ;
66using OpenQA . Selenium ;
77using OpenQA . Selenium . Chrome ;
8+ using OpenQA . Selenium . Chromium ;
89
910namespace SeleniumDocs . Browsers
1011{
@@ -44,8 +45,8 @@ public void Arguments()
4445 [ TestMethod ]
4546 public void SetBrowserLocation ( )
4647 {
47- string userDataDir = System . IO . Path . Combine ( System . IO . Path . GetTempPath ( ) , System . IO . Path . GetRandomFileName ( ) ) ;
48- System . IO . Directory . CreateDirectory ( userDataDir ) ;
48+ string userDataDir = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
49+ Directory . CreateDirectory ( userDataDir ) ;
4950 var options = new ChromeOptions ( ) ;
5051 options . AddArgument ( $ "--user-data-dir={ userDataDir } ") ;
5152 options . AddArgument ( "--no-sandbox" ) ;
@@ -98,32 +99,12 @@ public void LogsToFile()
9899 }
99100
100101 [ TestMethod ]
101- [ Ignore ( "Not implemented" ) ]
102- public void LogsToConsole ( )
103- {
104- var stringWriter = new StringWriter ( ) ;
105- var originalOutput = Console . Out ;
106- Console . SetOut ( stringWriter ) ;
107-
108- var service = ChromeDriverService . CreateDefaultService ( ) ;
109-
110- //service.LogToConsole = true;
111-
112- driver = new ChromeDriver ( service ) ;
113-
114- Assert . IsTrue ( stringWriter . ToString ( ) . Contains ( "Starting ChromeDriver" ) ) ;
115- Console . SetOut ( originalOutput ) ;
116- stringWriter . Dispose ( ) ;
117- }
118-
119- [ TestMethod ]
120- [ Ignore ( "Not implemented" ) ]
121102 public void LogsLevel ( )
122103 {
123104 var service = ChromeDriverService . CreateDefaultService ( ) ;
124105 service . LogPath = GetLogLocation ( ) ;
125106
126- // service.LogLevel = ChromiumDriverLogLevel.Debug
107+ service . LogLevel = ChromiumDriverLogLevel . Debug ;
127108
128109 driver = new ChromeDriver ( service ) ;
129110
@@ -133,22 +114,21 @@ public void LogsLevel()
133114 }
134115
135116 [ TestMethod ]
136- [ Ignore ( "Not implemented" ) ]
137117 public void ConfigureDriverLogs ( )
138118 {
139119 var service = ChromeDriverService . CreateDefaultService ( ) ;
140120 service . LogPath = GetLogLocation ( ) ;
141121 service . EnableVerboseLogging = true ;
142122
143123 service . EnableAppendLog = true ;
144- // service.readableTimeStamp = true;
124+ service . ReadableTimestamp = true ;
145125
146126 driver = new ChromeDriver ( service ) ;
147127
148128 driver . Quit ( ) ; // Close the Service log file before reading
149129 var lines = File . ReadLines ( GetLogLocation ( ) ) ;
150- var regex = new Regex ( @"\[\d\d-\d\d-\d\d\d\d" ) ;
151- Assert . IsNotNull ( lines . FirstOrDefault ( line => regex . Matches ( "" ) . Count > 0 ) ) ;
130+ var regex = new Regex ( @"\[\d\d-\d\d-\d\d\d\d \d\d:\d\d:\d\d\.\d+\] " ) ;
131+ Assert . IsNotNull ( lines . FirstOrDefault ( line => regex . Matches ( line ) . Count > 0 ) ) ;
152132 }
153133
154134 [ TestMethod ]
@@ -169,7 +149,7 @@ public void DisableBuildCheck()
169149
170150 private string GetLogLocation ( )
171151 {
172- if ( _logLocation == null || ! File . Exists ( _logLocation ) )
152+ if ( string . IsNullOrEmpty ( _logLocation ) && ! File . Exists ( _logLocation ) )
173153 {
174154 _logLocation = Path . GetTempFileName ( ) ;
175155 }
0 commit comments