@@ -89,7 +89,7 @@ cd smartui-csharp-sample/LambdaTest.Selenium.Driver.Test
8989
9090``` cs
9191< ItemGroup >
92- < PackageReference Include = " LambdaTest.Selenium.Driver" Version = " 1.0.1 " / >
92+ < PackageReference Include = " LambdaTest.Selenium.Driver" Version = " 1.0.4 " / >
9393< / ItemGroup >
9494```
9595
@@ -191,42 +191,95 @@ Once, the configuration file will be created, you will be seeing the default con
191191
192192### **Step 6:** Adding SmartUI function to take screenshot
193193
194- - You can incorporate SmartUI into your custom `Selenium ` automation test (any platform ) script by adding the `smartuiSnapshot ` function in the required segment of selenium script of which we would like to take the screenshot , as shown below :
195-
194+ - You can incorporate SmartUI into your custom `Selenium ` automation test (any platform ) script by adding the `smartuiSnapshot ` function in the required segment of selenium script of which you would like to take the screenshot , as shown below :
196195
197- ```java
196+ ```csharp
198197using System ;
199198using System .Threading .Tasks ;
200199using OpenQA .Selenium ;
201200using OpenQA .Selenium .Chrome ;
202201using LambdaTest .Selenium .Driver ;
203202
204-
205203namespace LambdaTest .Selenium .TestProject
206204{
207- public static class LocalTest
208- {
209- public static async Task Run ()
205+ public static class LocalTest
210206 {
211- using IWebDriver driver = new ChromeDriver ();
212- try
213- {
214- Console .WriteLine (" Driver started" );
215- driver .Navigate ().GoToUrl (" Required URL" );
216- await SmartUISnapshot .CaptureSnapshot (driver , " Screenshot Name" ); // utilize this function to take the dom snapshot of your test
217- }
218- catch (Exception ex )
219- {
220- Console .WriteLine (ex );
221- }
222- finally
223- {
224- driver .Quit ();
225- }
207+ public static async Task Run ()
208+ {
209+ using IWebDriver driver = new ChromeDriver ();
210+ try
211+ {
212+ Console .WriteLine (" Driver started" );
213+ driver .Navigate ().GoToUrl (" Required URL" );
214+ await SmartUISnapshot .CaptureSnapshot (driver , " Screenshot Name" ); // utilize this function to take the dom snapshot of your test
215+ }
216+ catch (Exception ex )
217+ {
218+ Console .WriteLine (ex );
219+ }
220+ finally
221+ {
222+ driver .Quit ();
223+ }
224+ }
226225 }
227- }
228226}
227+ ```
228+
229+ #### **Additional Functionality: Using `sync` Option in SmartUI C# SDK**
230+
231+ You can enable synchronous snapshot status response by setting the `sync ` option to `true ` in the options dictionary . This allows you to wait for the snapshot status and receive the result directly in your test script .
232+
233+ ::: info
234+ - The `sync ` functionality is supported only in LambdaTest .Selenium .Driver version **1.0.4 and above **.
235+ :::
229236
237+ ** Set the sync value in options :**
238+
239+ ```csharp
240+ var optionsForSync = new Dictionary <string , object >
241+ {
242+ { " sync" , true },
243+ { " timeout" , 100 } // timeout in seconds (30-900, default 600)
244+ };
245+
246+ Console .WriteLine (" Driver started" );
247+ driver .Navigate ().GoToUrl (" https://www.lambdatest.com" );
248+ var result = await SmartUISnapshot .CaptureSnapshot (driver , " NYC" , optionsForSync );
249+ Console .WriteLine (result );
250+ ```
251+
252+ ** Notes :**
253+ - The default value of `sync ` is `false ` if not specified .
254+ - The `timeout ` option defines how long to wait for the snapshot status response (in seconds ). Allowed range : 30 - 900 , default is 600 .
255+ - When `sync ` is `true `, the `result ` variable will hold the value of the snapshot status response .
256+
257+
258+ ** Sample response :**
259+ ```json
260+ {
261+ " snapshotName" : " Sync-True" ,
262+ " snapshotUUID" : " 95226130-72b6-4d45-ad6d-4ad8ddsa1" ,
263+ " buildId" : " 8e0c078d-e85a-41ae-a8d5-4a0dsdf8bbd5" ,
264+ " snapshotStatus" : " failed" ,
265+ " startedProcessingAt" : " 2025-08-26 09:58:21" ,
266+ " finishedProcessingAt" : " 2025-08-26 10:03:12" ,
267+ " screenshots" : [
268+ {
269+ " captured_image" : " <URL>" ,
270+ " baseline_image" : " <URL>" ,
271+ " browser_name" : " firefox" ,
272+ " viewport" : " 1028" ,
273+ " mismatch_percentage" : 89 . 58 ,
274+ " status" : " Changes found" ,
275+ " captured_image_timestamp" : " 2025-08-26 10:00:40" ,
276+ " compared_image_timestamp" : " 2025-08-26 10:00:58" ,
277+ " captured_diff" : " <URL>" ,
278+ " baseline_diff" : " <URL>" ,
279+ },
280+ // ... more screenshots in the same format
281+ ]
282+ }
230283```
231284
232285### **Step 7:** Execute the Tests on SmartUI Cloud
0 commit comments