Skip to content

Commit 512ac08

Browse files
committed
remove selenium deps
1 parent 89010cf commit 512ac08

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>net8.0;net48</TargetFrameworks>
44
<PackageId>LambdaTest.Selenium.Driver</PackageId>
5-
<Version>1.0.5</Version>
5+
<Version>1.0.6</Version>
66
<Authors>Lambdatest-SmartUI</Authors>
77
<Company>LambdaTest</Company>
88
<Description>LambdaTest C# Selenium SDK</Description>
@@ -13,10 +13,9 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Selenium.Support" Version="4.21.0" />
17-
<PackageReference Include="Selenium.WebDriver" Version="4.21.0" />
1816
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
1917
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
18+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
2019
</ItemGroup>
2120

2221
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">

LambdaTest.Selenium.Driver/SmartUI.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.Text.Json;
44
using System.Threading.Tasks;
55
using Microsoft.Extensions.Logging;
6-
using OpenQA.Selenium;
7-
using OpenQA.Selenium.Remote;
86
using LambdaTest.Sdk.Utils;
97

108
namespace LambdaTest.Selenium.Driver
@@ -13,7 +11,7 @@ public static class SmartUISnapshot
1311
{
1412
private static readonly ILogger SmartUILogger = Logger.CreateLogger("Lambdatest.Selenium.Driver");
1513

16-
public static async Task<String> CaptureSnapshot(IWebDriver driver, string name, Dictionary<string, object> options = null)
14+
public static async Task<String> CaptureSnapshot(dynamic driver, string name, Dictionary<string, object> options = null)
1715
{
1816
if (string.IsNullOrEmpty(name))
1917
{
@@ -43,14 +41,20 @@ public static async Task<String> CaptureSnapshot(IWebDriver driver, string name,
4341

4442
string script = domSerializerScript.Data.Dom;
4543

46-
((IJavaScriptExecutor)driver).ExecuteScript(script);
44+
// Execute script using dynamic driver
45+
driver.ExecuteScript(script);
4746

4847
// Extract sessionId from driver
4948
string sessionId = "";
50-
if (driver is RemoteWebDriver remoteDriver)
49+
try
5150
{
52-
sessionId = remoteDriver.SessionId.ToString();
51+
sessionId = driver.SessionId?.ToString() ?? "";
5352
}
53+
catch
54+
{
55+
// SessionId not available or accessible
56+
}
57+
5458
if (options == null)
5559
{
5660
options = new Dictionary<string, object>();
@@ -68,7 +72,8 @@ public static async Task<String> CaptureSnapshot(IWebDriver driver, string name,
6872
url: document.URL
6973
});";
7074

71-
var domJSON = (string)((IJavaScriptExecutor)driver).ExecuteScript(snapshotScript);
75+
// Execute script and get DOM JSON using dynamic driver
76+
var domJSON = (string)driver.ExecuteScript(snapshotScript);
7277

7378
if (domJSON == null)
7479
{
@@ -116,17 +121,17 @@ public static async Task<String> CaptureSnapshot(IWebDriver driver, string name,
116121
SmartUILogger.LogInformation($"Snapshot captured: {name}");
117122

118123
// Get Snapshot Status
119-
var timeout=600;
124+
var timeout = 600;
120125
if (options.ContainsKey("timeout"))
121126
{
122-
var tempTimeout= (int)options["timeout"];
123-
if (tempTimeout<30||tempTimeout>900)
127+
var tempTimeout = (int)options["timeout"];
128+
if (tempTimeout < 30 || tempTimeout > 900)
124129
{
125130
SmartUILogger.LogWarning("Timeout value is out of range(30-900). Defaulting to 600 seconds.");
126131
}
127132
else
128133
{
129-
timeout=tempTimeout;
134+
timeout = tempTimeout;
130135
}
131136
}
132137
var snapshotStatusJSON = await LambdaTest.Sdk.Utils.SmartUI.GetSnapshotStatus(contextId, timeout, name);

0 commit comments

Comments
 (0)