Skip to content

Commit 07032bd

Browse files
committed
Enabling service tests after 4.35 release
1 parent 69669e2 commit 07032bd

File tree

3 files changed

+16
-56
lines changed

3 files changed

+16
-56
lines changed

examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.VisualStudio.TestTools.UnitTesting;
66
using OpenQA.Selenium;
77
using OpenQA.Selenium.Chrome;
8+
using OpenQA.Selenium.Chromium;
89

910
namespace 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
}

examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.RegularExpressions;
55
using Microsoft.VisualStudio.TestTools.UnitTesting;
66
using OpenQA.Selenium;
7+
using OpenQA.Selenium.Chromium;
78
using OpenQA.Selenium.Edge;
89

910
namespace SeleniumDocs.Browsers
@@ -92,32 +93,12 @@ public void LogsToFile()
9293
}
9394

9495
[TestMethod]
95-
[Ignore("Not implemented")]
96-
public void LogsToConsole()
97-
{
98-
var stringWriter = new StringWriter();
99-
var originalOutput = Console.Out;
100-
Console.SetOut(stringWriter);
101-
102-
var service = EdgeDriverService.CreateDefaultService();
103-
104-
//service.LogToConsole = true;
105-
106-
driver = new EdgeDriver(service);
107-
108-
Assert.IsTrue(stringWriter.ToString().Contains("Starting Microsoft Edge WebDriver"));
109-
Console.SetOut(originalOutput);
110-
stringWriter.Dispose();
111-
}
112-
113-
[TestMethod]
114-
[Ignore("Not implemented")]
11596
public void LogsLevel()
11697
{
11798
var service = EdgeDriverService.CreateDefaultService();
11899
service.LogPath = GetLogLocation();
119100

120-
// service.LogLevel = ChromiumDriverLogLevel.Debug
101+
service.LogLevel = ChromiumDriverLogLevel.Debug;
121102

122103
driver = new EdgeDriver(service);
123104

@@ -127,22 +108,21 @@ public void LogsLevel()
127108
}
128109

129110
[TestMethod]
130-
[Ignore("Not implemented")]
131111
public void ConfigureDriverLogs()
132112
{
133113
var service = EdgeDriverService.CreateDefaultService();
134114
service.LogPath = GetLogLocation();
135115
service.EnableVerboseLogging = true;
136116

137117
service.EnableAppendLog = true;
138-
// service.readableTimeStamp = true;
118+
service.ReadableTimestamp = true;
139119

140120
driver = new EdgeDriver(service);
141121

142122
driver.Quit(); // Close the Service log file before reading
143123
var lines = File.ReadLines(GetLogLocation());
144-
var regex = new Regex(@"\[\d\d-\d\d-\d\d\d\d");
145-
Assert.IsNotNull(lines.FirstOrDefault(line => regex.Matches("").Count > 0));
124+
var regex = new Regex(@"\[\d\d-\d\d-\d\d\d\d \d\d:\d\d:\d\d\.\d+\]");
125+
Assert.IsNotNull(lines.FirstOrDefault(line => regex.Matches(line).Count > 0));
146126
}
147127

148128
[TestMethod]
@@ -163,7 +143,7 @@ public void DisableBuildCheck()
163143

164144
private string GetLogLocation()
165145
{
166-
if (_logLocation == null || !File.Exists(_logLocation))
146+
if (string.IsNullOrEmpty(_logLocation) && !File.Exists(_logLocation))
167147
{
168148
_logLocation = Path.GetTempFileName();
169149
}

examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void InstallUnsignedAddon()
174174

175175
private string GetLogLocation()
176176
{
177-
if (String.IsNullOrEmpty(_logLocation) && !File.Exists(_logLocation))
177+
if (string.IsNullOrEmpty(_logLocation) && !File.Exists(_logLocation))
178178
{
179179
_logLocation = Path.GetTempFileName();
180180
}
@@ -184,7 +184,7 @@ private string GetLogLocation()
184184

185185
private string GetTempDirectory()
186186
{
187-
if (String.IsNullOrEmpty(_tempPath) && !File.Exists(_tempPath))
187+
if (string.IsNullOrEmpty(_tempPath) && !File.Exists(_tempPath))
188188
{
189189
_tempPath = Path.GetTempPath();
190190
}

0 commit comments

Comments
 (0)