Skip to main content

Upload PDFs via CLI

Prerequisites for Using Smart UI

  • Familiarity with command-line tools is essential.
  • Visit the LambdaTest SmartUI page and log in with your credentials.
  • Obtain your LT_USERNAME and LT_ACCESS_KEY by clicking on the Access Key button, located at the top right corner of your dashboard.

Step 1: Establishing a SmartUI Project

To initiate a SmartUI PDF Comparison Project, adhere to the following instructions:

  1. Navigate to the SmartUI Projects Page.
  2. Tap on the new project button.
  3. Specify your platform type as PDF.
  4. Provide your project name, designate approvers, and add tags (optional).
  5. Confirm your entry by clicking on Submit.

Once your project is active, retrieve your Project Token from the application. Here's an example of a project token:

projectToken = "123456#1234abcd-****-****-****-************"

Step 1: Install the SmartUI CLI

Install the CLI globally using npm:

npm install -g @lambdatest/smartui-cli

Step 2: Setup your credentials

export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"
export PROJECT_TOKEN="123456#1234abcd-****-****-****-************"
cmd

Step 3: Upload PDFs Using CLI

Use the upload-pdf command to upload one or multiple PDF files from a directory:

smartui upload-pdf <directory_or_filename> [options]

Arguments:

  • directory_or_filename: Path to a single PDF file or a directory containing multiple PDFs.

Options:

  • --fetch-results [filename]: Fetch test results after upload. Optionally specify an output file (e.g., results.json).
  • --buildName <string>: Assign a custom name to the build.
  • --projectToken <token>: Specify the project token (if not set as environment variable).

Example Usage:

Upload all PDFs from a folder and name the build:

smartui upload-pdf ./pdfs/ --buildName "Release-v2.1"

Upload a single PDF file:

smartui upload-pdf ./document.pdf --buildName "Single-PDF-Test"

Fetch results and save to a file:

smartui upload-pdf ./spec.pdf --fetch-results results.json

Upload with custom project token:

smartui upload-pdf ./pdfs/ --projectToken "123456#1234abcd-****-****-****-************" --buildName "Custom-Build"

Advanced CLI Options

Batch Processing

Process multiple directories:

smartui upload-pdf ./documents/ --buildName "Batch-1"
smartui upload-pdf ./reports/ --buildName "Batch-2"

CI/CD Integration

Example for GitHub Actions:

- name: Upload PDFs to SmartUI
run: |
smartui upload-pdf ./generated-pdfs/ --buildName "${{ github.sha }}" --fetch-results test-results.json

Use Cases

  • CI/CD Pipelines: Integrate PDF testing into automated deployment workflows
  • Batch Processing: Upload multiple PDFs efficiently from command line
  • Automated Testing: Schedule PDF uploads as part of automated test suites
  • Developer Workflows: Quick PDF testing during development and debugging

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles