Skip to content

Commit b46466a

Browse files
authored
Merge pull request #4 from LambdaTest/stage
Release PR: 1.0.3
2 parents 90404e4 + b8ceaed commit b46466a

File tree

6 files changed

+28
-10
lines changed

6 files changed

+28
-10
lines changed

LambdaTest.Sdk.Utils/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static string GetSmartUIServerAddress()
99
var address = Environment.GetEnvironmentVariable("SMARTUI_SERVER_ADDRESS");
1010
if (string.IsNullOrEmpty(address))
1111
{
12-
throw new Exception("SmartUI server address not found");
12+
return "http://localhost:49152";
1313
}
1414
return address;
1515
}

LambdaTest.Sdk.Utils/LambdaTest.Sdk.Utils.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
44
<PackageId>LambdaTest.Sdk.Utils</PackageId>
5-
<Version>1.0.1</Version>
5+
<Version>1.0.3</Version>
66
<Authors>Lambdatest-SmartUI</Authors>
77
<Company>LambdaTest</Company>
88
<Description>LambdaTest SDK Utilities for SmartUI CLI in C#</Description>

LambdaTest.Sdk.Utils/SmartUI.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,18 @@ public static async Task<string> PostSnapshot(DomObject snapshot, string pkg, D
8585
throw new Exception("post snapshot failed", e);
8686
}
8787
}
88+
89+
public class Resource
90+
{
91+
public string content { get; set; } = string.Empty;
92+
public string mimetype { get; set; } = string.Empty;
93+
public string url { get; set; } = string.Empty;
94+
}
8895
public class DomContent
8996
{
9097
public string html { get; set; } = string.Empty;
9198
public List<string> warnings { get; set; } = new List<string>();
92-
public List<string> resources { get; set; } = new List<string>();
99+
public List<Resource> resources { get; set; } = new List<Resource>();
93100
public List<string> hints { get; set; } = new List<string>();
94101
}
95102

LambdaTest.Selenium.Driver/LambdaTest.Selenium.Driver.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
44
<PackageId>LambdaTest.Selenium.Driver</PackageId>
5-
<Version>1.0.1</Version>
5+
<Version>1.0.3</Version>
66
<Authors>Lambdatest-SmartUI</Authors>
77
<Company>LambdaTest</Company>
88
<Description>LambdaTest C# Selenium SDK </Description>
99
<ImplicitUsings>enable</ImplicitUsings>
1010
<Nullable>enable</Nullable>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="LambdaTest.Sdk.Utils" Version="1.0.0" />
13+
<PackageReference Include="LambdaTest.Sdk.Utils" Version="1.0.2" />
1414
<PackageReference Include="Selenium.Support" Version="4.21.0" />
1515
<PackageReference Include="Selenium.WebDriver" Version="4.21.0" />
1616
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />

LambdaTest.Selenium.Driver/SmartUI.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace LambdaTest.Selenium.Driver
1010
{
1111
public static class SmartUISnapshot
1212
{
13-
private static readonly ILogger SmartUILogger = Logger.CreateLogger("Lambdatest.Selenium.Driver");
13+
private static readonly ILogger SmartUILogger = Logger.CreateLogger("Lambdatest.Selenium.Driver");
1414

1515
public static async Task CaptureSnapshot(IWebDriver driver, string name, Dictionary<string, object>? options = null)
1616
{
@@ -44,6 +44,18 @@ public static async Task CaptureSnapshot(IWebDriver driver, string name, Diction
4444

4545
((IJavaScriptExecutor)driver).ExecuteScript(script);
4646

47+
// Extract sessionId from driver
48+
string sessionId = (driver as IRemoteWebDriver)?.SessionId.ToString();
49+
if (!string.IsNullOrEmpty(sessionId))
50+
{
51+
// Append sessionId to options
52+
if (options == null)
53+
{
54+
options = new Dictionary<string, object>();
55+
}
56+
options["sessionId"] = sessionId;
57+
}
58+
4759
var optionsJSON = JsonSerializer.Serialize(options);
4860
var snapshotScript = @"
4961
var options = " + optionsJSON + @";
@@ -114,7 +126,6 @@ private class FetchDomSerializerResponse
114126
{
115127
public FetchDomSerializerData Data { get; set; } = new FetchDomSerializerData();
116128
}
117-
118129
private class FetchDomSerializerData
119130
{
120131
public string Dom { get; set; } = string.Empty;
@@ -123,7 +134,7 @@ private class DomJSONContent
123134
{
124135
public string html { get; set; } = string.Empty;
125136
public List<string> warnings { get; set; } = new List<string>();
126-
public List<string> resources { get; set; } = new List<string>();
137+
public List<LambdaTest.Sdk.Utils.SmartUI.Resource> resources { get; set; } = new List<LambdaTest.Sdk.Utils.SmartUI.Resource>();
127138
public List<string> hints { get; set; } = new List<string>();
128139
}
129140
private class DomDeserializerResponse

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ LambdaTest.Selenium.Driver integrates seamlessly with Selenium WebDriver to capt
2727
To install the packages, use the .NET CLI:
2828

2929
```sh
30-
dotnet add package LambdaTest.Sdk.Utils --version 1.0.1
31-
dotnet add package LambdaTest.Selenium.Driver --version 1.0.1
30+
dotnet add package LambdaTest.Sdk.Utils --version 1.0.3
31+
dotnet add package LambdaTest.Selenium.Driver --version 1.0.3
3232
```
3333

3434
## License

0 commit comments

Comments
 (0)