Skip to content

Commit 3daa319

Browse files
authored
[dotnet] add support for Safari Technology Preview (#12342)
1 parent 7f56114 commit 3daa319

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

dotnet/src/webdriver/Safari/SafariDriverService.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public sealed class SafariDriverService : DriverService
3232
{
3333
private const string DefaultSafariDriverServiceExecutableName = "safaridriver";
3434
private const string DefaultSafariDriverServiceExecutablePath = "/usr/bin";
35+
private const string DefaultSafariPreviewDriverServiceExecutablePath = "/Applications/Safari Technology Preview.app/Contents/MacOS/";
3536

3637
private static readonly Uri SafariDriverDownloadUrl = new Uri("http://apple.com");
3738

@@ -164,6 +165,20 @@ public static SafariDriverService CreateDefaultService()
164165
return CreateDefaultService(DefaultSafariDriverServiceExecutablePath);
165166
}
166167

168+
/// <summary>
169+
/// Creates a default instance of the SafariDriverService.
170+
/// </summary>
171+
/// <returns>A SafariDriverService that implements default settings.</returns>
172+
public static SafariDriverService CreateDefaultService(SafariOptions options)
173+
{
174+
if (options.TechnologyPreview)
175+
{
176+
return CreateDefaultService(DefaultSafariPreviewDriverServiceExecutablePath);
177+
}
178+
179+
return CreateDefaultService(DefaultSafariDriverServiceExecutablePath);
180+
}
181+
167182
/// <summary>
168183
/// Creates a default instance of the SafariDriverService using a specified path to the SafariDriver executable.
169184
/// </summary>

dotnet/src/webdriver/Safari/SafariOptions.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,39 @@ public class SafariOptions : DriverOptions
4747
{
4848
private const string BrowserNameValue = "safari";
4949
private const string EnableAutomaticInspectionSafariOption = "safari:automaticInspection";
50-
private const string EnableAutomticProfilingSafariOption = "safari:automaticProfiling";
50+
private const string EnableAutomaticProfilingSafariOption = "safari:automaticProfiling";
5151

5252
private bool enableAutomaticInspection = false;
5353
private bool enableAutomaticProfiling = false;
54+
private bool technologyPreview = false;
5455

5556
/// <summary>
5657
/// Initializes a new instance of the <see cref="SafariOptions"/> class.
5758
/// </summary>
5859
public SafariOptions() : base()
5960
{
6061
this.BrowserName = BrowserNameValue;
62+
this.technologyPreview = false;
6163
this.AddKnownCapabilityName(SafariOptions.EnableAutomaticInspectionSafariOption, "EnableAutomaticInspection property");
62-
this.AddKnownCapabilityName(SafariOptions.EnableAutomticProfilingSafariOption, "EnableAutomaticProfiling property");
64+
this.AddKnownCapabilityName(SafariOptions.EnableAutomaticProfilingSafariOption, "EnableAutomaticProfiling property");
65+
}
66+
67+
/// <summary>
68+
/// Allows the Options class to be used with a Safari Technology Preview driver
69+
/// </summary>
70+
public void UseTechnologyPreview()
71+
{
72+
this.technologyPreview = true;
73+
this.BrowserName = "Safari Technology Preview";
74+
}
75+
76+
/// <summary>
77+
/// Gets or sets a value indicating whether to have the driver preload the
78+
/// Web Inspector and JavaScript debugger in the background.
79+
/// </summary>
80+
public bool TechnologyPreview
81+
{
82+
get { return this.technologyPreview; }
6383
}
6484

6585
/// <summary>
@@ -98,7 +118,7 @@ public override ICapabilities ToCapabilities()
98118

99119
if (this.enableAutomaticProfiling)
100120
{
101-
capabilities.SetCapability(EnableAutomticProfilingSafariOption, true);
121+
capabilities.SetCapability(EnableAutomaticProfilingSafariOption, true);
102122
}
103123

104124
return capabilities.AsReadOnly();

dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public static SafariDriverService DefaultService
2222

2323
public static SafariOptions DefaultOptions
2424
{
25-
get { return new SafariOptions(); }
25+
get
26+
{
27+
SafariOptions options = new SafariOptions();
28+
options.UseTechnologyPreview();
29+
return options;
30+
}
2631
}
2732
}
2833
}

0 commit comments

Comments
 (0)