Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SAUCE_USERNAME and SAUCE_ACCESS_KEY #4

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions visual-dotnet/SauceLabs.Visual/VisualClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public class VisualClient : IDisposable
public bool CaptureDom { get; set; } = false;
private ResiliencePipeline _retryPipeline;

/// <summary>
/// Creates a new instance of <c>VisualClient</c>
/// </summary>
/// <param name="wd">the instance of the WebDriver session</param>
/// <param name="region">the Sauce Labs region to connect to</param>
public VisualClient(WebDriver wd, Region region) : this(wd, region, Environment.GetEnvironmentVariable("SAUCE_USERNAME"), Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"))
{
}

/// <summary>
/// Creates a new instance of <c>VisualClient</c>
/// </summary>
/// <param name="wd">the instance of the WebDriver session</param>
/// <param name="region">the Sauce Labs region to connect to</param>
/// <param name="buildOptions">the options of the build creation</param>
public VisualClient(WebDriver wd, Region region, CreateBuildOptions buildOptions) : this(wd, region, Environment.GetEnvironmentVariable("SAUCE_USERNAME"), Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"), buildOptions)
{
}

/// <summary>
/// Creates a new instance of <c>VisualClient</c>
/// </summary>
Expand All @@ -47,6 +66,11 @@ public class VisualClient : IDisposable
/// <param name="buildOptions">the options of the build creation</param>
public VisualClient(WebDriver wd, Region region, string username, string accessKey, CreateBuildOptions buildOptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to have:
we need to add a description for rest parameters here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which rest parameters are you mentioning ?

{
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(accessKey))
{
throw new VisualClientException("Username or Access Key not set");
}

_api = new VisualApi<WebDriver>(wd, region, username, accessKey);
_sessionId = wd.SessionId.ToString();
_jobId = wd.Capabilities.HasCapability("jobUuid") ? wd.Capabilities.GetCapability("jobUuid").ToString() : _sessionId;
Expand Down