Skip to content

Commit 227c650

Browse files
authored
Add support for SAUCE_USERNAME and SAUCE_ACCESS_KEY (#4)
1 parent 3f61d7d commit 227c650

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

visual-dotnet/SauceLabs.Visual/VisualClient.cs

+24
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ public class VisualClient : IDisposable
2626
public bool CaptureDom { get; set; } = false;
2727
private ResiliencePipeline _retryPipeline;
2828

29+
/// <summary>
30+
/// Creates a new instance of <c>VisualClient</c>
31+
/// </summary>
32+
/// <param name="wd">the instance of the WebDriver session</param>
33+
/// <param name="region">the Sauce Labs region to connect to</param>
34+
public VisualClient(WebDriver wd, Region region) : this(wd, region, Environment.GetEnvironmentVariable("SAUCE_USERNAME"), Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"))
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Creates a new instance of <c>VisualClient</c>
40+
/// </summary>
41+
/// <param name="wd">the instance of the WebDriver session</param>
42+
/// <param name="region">the Sauce Labs region to connect to</param>
43+
/// <param name="buildOptions">the options of the build creation</param>
44+
public VisualClient(WebDriver wd, Region region, CreateBuildOptions buildOptions) : this(wd, region, Environment.GetEnvironmentVariable("SAUCE_USERNAME"), Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"), buildOptions)
45+
{
46+
}
47+
2948
/// <summary>
3049
/// Creates a new instance of <c>VisualClient</c>
3150
/// </summary>
@@ -47,6 +66,11 @@ public class VisualClient : IDisposable
4766
/// <param name="buildOptions">the options of the build creation</param>
4867
public VisualClient(WebDriver wd, Region region, string username, string accessKey, CreateBuildOptions buildOptions)
4968
{
69+
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(accessKey))
70+
{
71+
throw new VisualClientException("Username or Access Key not set");
72+
}
73+
5074
_api = new VisualApi<WebDriver>(wd, region, username, accessKey);
5175
_sessionId = wd.SessionId.ToString();
5276
_jobId = wd.Capabilities.HasCapability("jobUuid") ? wd.Capabilities.GetCapability("jobUuid").ToString() : _sessionId;

0 commit comments

Comments
 (0)