From 651d2c781db183cdad84134f098da020af0f0913 Mon Sep 17 00:00:00 2001 From: RushilK7 Date: Mon, 6 Oct 2025 17:33:01 +0530 Subject: [PATCH 1/2] pdf doc fix --- docs/smartui-pdf-comparison.md | 157 ++++++++++++++++++++++++++++++++- 1 file changed, 155 insertions(+), 2 deletions(-) diff --git a/docs/smartui-pdf-comparison.md b/docs/smartui-pdf-comparison.md index 459b639ad..caeeb0670 100644 --- a/docs/smartui-pdf-comparison.md +++ b/docs/smartui-pdf-comparison.md @@ -200,6 +200,161 @@ smartui upload-pdf ./spec.pdf --fetch-results results.json This CLI method streamlines PDF uploads and result retrieval, making it ideal for CI/CD pipelines and automated workflows. +## Option 3: Uploading PDFs via SmartUI Java SDK + +For developers who prefer programmatic control, SmartUI provides a Java SDK to upload PDFs and manage visual regression testing programmatically. + +### Step 1: Install the SmartUI Java SDK + +Add the SmartUI Java SDK to your `pom.xml`: + +```xml + + io.github.lambdatest + lambdatest-java-sdk + 1.0.18 + +``` + +### Step 2: Set up your credentials + + + + + +
+ + {`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" +export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}" +export PROJECT_TOKEN="123456#1234abcd-****-****-****-************"`} + +
+ +
+ + + +
+ + {`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" +set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}" +set PROJECT_TOKEN="123456#1234abcd-****-****-****-************"`} + +
+ +
+ + + +
+ + {`$Env:LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" +$Env:LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}" +$Env:PROJECT_TOKEN="123456#1234abcd-****-****-****-************"` + + +
+ +
+ +
+ +### Step 3: Upload PDFs using Java SDK + +You can upload PDFs in two modes: + + + + + +Upload pre-existing PDFs from your local machine: + +```java +import io.github.lambdatest.SmartUIConfig; +import io.github.lambdatest.SmartUIPdf; +import io.github.lambdatest.models.FormattedResults; + +public class SmartuiPdfLocalTest { + public void uploadLocalPdf() throws Exception { + String projectToken = System.getenv("PROJECT_TOKEN"); + + SmartUIConfig config = new SmartUIConfig() + .withProjectToken(projectToken) + .withFetchResult(true); + + SmartUIPdf pdfUploader = new SmartUIPdf(config); + + // Upload PDF file + String pdfPath = "path/to/your/document.pdf"; + FormattedResults result = pdfUploader.uploadPDF(pdfPath); + + System.out.println("Upload result: " + result); + } +} +``` + + + + + +Upload PDFs downloaded during LambdaTest cloud test execution: + +```java +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.remote.RemoteWebDriver; +import java.io.File; +import java.io.FileOutputStream; +import java.util.Base64; + +public class SmartuiPdfCloudTest { + public void uploadCloudPdf(WebDriver driver) throws Exception { + String projectToken = System.getenv("PROJECT_TOKEN"); + + // Download PDF from cloud session + String base64Content = (String) ((JavascriptExecutor) driver) + .executeAsyncScript("lambda-file-content=LambdaTest.pdf"); + + // Convert base64 to PDF file + byte[] pdfBytes = Base64.getDecoder().decode(base64Content); + File pdfFile = new File("downloaded.pdf"); + try (FileOutputStream fos = new FileOutputStream(pdfFile)) { + fos.write(pdfBytes); + } + + // Upload to SmartUI + SmartUIConfig config = new SmartUIConfig() + .withProjectToken(projectToken) + .withFetchResult(true); + + SmartUIPdf pdfUploader = new SmartUIPdf(config); + FormattedResults result = pdfUploader.uploadPDF(pdfFile.getAbsolutePath()); + + System.out.println("Upload result: " + result); + } +} +``` + + + + + +### Step 4: Configuration Options + +| Method | Description | +|-------|-------------| +| `.withProjectToken(token)` | Required. Your SmartUI project token. | +| `.withFetchResult(true)` | Optional. Returns structured test results. | +| `.withBuildName("v2.1")` | Optional. Assign a custom build name. | + +### Step 5: Run your tests + +```bash +mvn test +``` + +The SDK method provides programmatic control over PDF uploads and is ideal for integration into existing Java-based test automation frameworks. + ## Use Cases of Smart PDF Comparison 1. **Software Documentation**: In software development, PDF comparison can be utilized to ensure the accuracy and consistency of user manuals, system documentation, and more. It can help in tracking changes made in the document across different software versions or updates. @@ -213,5 +368,3 @@ This CLI method streamlines PDF uploads and result retrieval, making it ideal fo 5. **Quality Assurance**: In industries where accuracy is paramount, such as manufacturing or engineering, PDF comparison can be used for quality assurance. Comparing design specs, product blueprints, or operational guidelines can ensure consistency and adherence to quality standards. 6. **Archiving and Record Keeping**: For businesses or organizations that need to maintain records over a long period, PDF comparison can help verify the accuracy and integrity of these archives. It can highlight any alterations or modifications made to a document over time. - -In summary, PDF comparison is a versatile tool that can streamline workflows, improve accuracy, and enhance productivity in many different sectors and use cases. \ No newline at end of file From 9aed37d16bedd7a3e2120c869a74f60d7bc02566 Mon Sep 17 00:00:00 2001 From: RushilK7 Date: Mon, 6 Oct 2025 20:10:06 +0530 Subject: [PATCH 2/2] smartui pdf sdk fixes --- docs/smartui-pdf-comparison.md | 49 +++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/docs/smartui-pdf-comparison.md b/docs/smartui-pdf-comparison.md index caeeb0670..f7c9c5dc5 100644 --- a/docs/smartui-pdf-comparison.md +++ b/docs/smartui-pdf-comparison.md @@ -204,7 +204,16 @@ This CLI method streamlines PDF uploads and result retrieval, making it ideal fo For developers who prefer programmatic control, SmartUI provides a Java SDK to upload PDFs and manage visual regression testing programmatically. -### Step 1: Install the SmartUI Java SDK +### Step 1: Clone the Sample Project + +First, clone the sample project to get started: + +```bash +git clone https://github.com/LambdaTest/junit-selenium-sample.git +cd junit-selenium-sample +``` + +### Step 2: Install the SmartUI Java SDK Add the SmartUI Java SDK to your `pom.xml`: @@ -216,7 +225,13 @@ Add the SmartUI Java SDK to your `pom.xml`: ``` -### Step 2: Set up your credentials +Then compile your project: + +```bash +mvn clean compile +``` + +### Step 3: Set up your credentials @@ -250,8 +265,7 @@ set PROJECT_TOKEN="123456#1234abcd-****-****-****-************"`} {`$Env:LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" $Env:LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}" -$Env:PROJECT_TOKEN="123456#1234abcd-****-****-****-************"` - +$Env:PROJECT_TOKEN="123456#1234abcd-****-****-****-************"`} @@ -259,7 +273,7 @@ $Env:PROJECT_TOKEN="123456#1234abcd-****-****-****-************"` -### Step 3: Upload PDFs using Java SDK +### Step 4: Upload PDFs using Java SDK You can upload PDFs in two modes: @@ -269,6 +283,8 @@ You can upload PDFs in two modes: Upload pre-existing PDFs from your local machine: +> 📁 **Sample File**: [`SmartuiPdfLocalTest.java`](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/smartuiPdf/SmartuiPdfLocalTest.java) + ```java import io.github.lambdatest.SmartUIConfig; import io.github.lambdatest.SmartUIPdf; @@ -299,6 +315,8 @@ public class SmartuiPdfLocalTest { Upload PDFs downloaded during LambdaTest cloud test execution: +> 📁 **Sample File**: [`SmartuiPdfCloudTest.java`](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/smartuiPdf/SmartuiPdfCloudTest.java) + ```java import org.openqa.selenium.WebDriver; import org.openqa.selenium.JavascriptExecutor; @@ -339,7 +357,7 @@ public class SmartuiPdfCloudTest { -### Step 4: Configuration Options +### Step 5: Configuration Options | Method | Description | |-------|-------------| @@ -347,7 +365,7 @@ public class SmartuiPdfCloudTest { | `.withFetchResult(true)` | Optional. Returns structured test results. | | `.withBuildName("v2.1")` | Optional. Assign a custom build name. | -### Step 5: Run your tests +### Step 6: Run your tests ```bash mvn test @@ -357,14 +375,9 @@ The SDK method provides programmatic control over PDF uploads and is ideal for i ## Use Cases of Smart PDF Comparison -1. **Software Documentation**: In software development, PDF comparison can be utilized to ensure the accuracy and consistency of user manuals, system documentation, and more. It can help in tracking changes made in the document across different software versions or updates. - -2. **Legal and Compliance Checks**: In legal practices and compliance-heavy industries, comparing different versions of contracts, agreements, or regulatory documents is common. With PDF comparison, one can easily spot differences, alterations, or anomalies, ensuring every detail aligns with legal and compliance requirements. - -3. **Design Validation**: For graphic designers, artists, or anyone involved in the creation of visual content, PDF comparison can be used to validate design changes and ensure consistency across different versions of a design. - -4. **Proofreading and Editing**: In the publishing industry or any other industry where documents are created and edited, the PDF comparison feature can be invaluable. It can help detect any changes made between different versions of a document, allowing editors and proofreaders to quickly find and correct mistakes. - -5. **Quality Assurance**: In industries where accuracy is paramount, such as manufacturing or engineering, PDF comparison can be used for quality assurance. Comparing design specs, product blueprints, or operational guidelines can ensure consistency and adherence to quality standards. - -6. **Archiving and Record Keeping**: For businesses or organizations that need to maintain records over a long period, PDF comparison can help verify the accuracy and integrity of these archives. It can highlight any alterations or modifications made to a document over time. +- **Software Documentation**: Track changes and ensure consistency across document versions. +- **Legal & Compliance**: Spot differences in contracts or regulatory documents. +- **Design Validation**: Verify design updates and maintain visual consistency. +- **Proofreading**: Detect edits between document versions for quick review. +- **Quality Assurance**: Compare specs or blueprints to uphold standards. +- **Archiving**: Confirm integrity of records over time by highlighting modifications.