diff --git a/assets/images/hyperexecute/frameworks/karate/karate.png b/assets/images/hyperexecute/frameworks/karate/karate.png new file mode 100644 index 000000000..3d91ad52f Binary files /dev/null and b/assets/images/hyperexecute/frameworks/karate/karate.png differ diff --git a/docs/hyperexecute-karate-testing.md b/docs/hyperexecute-karate-testing.md new file mode 100644 index 000000000..efbf1bb55 --- /dev/null +++ b/docs/hyperexecute-karate-testing.md @@ -0,0 +1,206 @@ +--- +id: hyperexecute-karate-testing +title: Karate Automation on HyperExecute +hide_title: false +sidebar_label: Karate +description: Learn how to run Selenium automation tests on HyperExecute using the Karate framework +keywords: + - Karate + - Karate selenium + - Karate Java Selenium + - Karate automation testing + - selenium webdriver Karate + - selenium Karate testing tutorial + - Karate Java Selenium framework + - lambdatest Karate + - frameworks on lambdatest + - hyperexecute + - hyperexecute Karate testing + - hyperexecute Karate testing + - hyperexecute automation testing + - HyperExecute Selenium automation +url: https://www.lambdatest.com/support/docs/hyperexecute-karate-testing/ +site_name: LambdaTest +slug: hyperexecute-karate-testing/ +--- + +import CodeBlock from '@theme/CodeBlock'; +import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + +Karate is a popular open-source test automation framework for API, performance, and UI testing. It combines API testing with BDD-style syntax and supports parallel execution. + +## 🚀 Why choose HyperExecute for Karate Testing? +While Gatling is powerful on its own, running large-scale performance tests using traditional setups often introduces significant bottlenecks: + +### ⚠️ Challenges with Traditional Runners +- **Limited Parallelism:** Local runners struggle to scale effectively across multiple CPU cores or nodes. +- **Environment Inconsistencies:** Variations in environments lead to flaky tests and hard-to-reproduce bugs. +- **Manual Test Orchestration:** Managing dependencies, execution order, and reporting manually is error-prone. +- **Lack of Observability:** Debugging failures can be slow due to scattered logs and minimal visibility. + +### ✅ How HyperExecute Enhances Karate Testing +LambdaTest’s HyperExecute platform eliminates these issues with a modern, cloud-native test runner that offers: + +- **⚡ Smart Test Distribution:** HyperExecute auto-splits Karate feature files across multiple nodes to optimize execution speed. +- **🔒 Isolated Test Environments:** Each test job runs in a clean, sandboxed environment with controlled dependencies. +- **📦 Seamless Artifact Upload:** Automatically captures and uploads Karate test reports for easier analysis. +- **🔁 Built-in Retries & Stability Handling:** Reduce flakiness with automatic retries for failed test jobs. +- **📈 Unified Dashboard & Logs:** Get centralized access to logs, artifacts, and test metadata for efficient debugging. + +## Prerequisites +To run the Tests on HyperExecute from your Local System, you are required: + +- Your LambdaTest [Username and Access key](https://www.lambdatest.com/support/docs/hyperexecute-how-to-get-my-username-and-access-key/) +- [HyperExecute YAML](https://www.lambdatest.com/support/docs/hyperexecute-yaml-version0.2/) file which contains all the necessary instructions. +- [HyperExecute CLI](https://www.lambdatest.com/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/) in order to initiate a test execution Job . +- Setup the [Environmental Variable](https://www.lambdatest.com/support/docs/hyperexecute-environment-variable-setup/) + +## Run a Sample Project +### Step 1: Download Project +You can use your own project to configure and test it. For demo purposes, we are using the sample repository. + +:::tip Sample repo +Download or Clone the code sample for the Karate from the LambdaTest GitHub repository to run the tests on the HyperExecute. + +Image View on GitHub +::: + +### Step 2: Download the CLI in your Project +Download the HyperExecute CLI and copy it into the root folder of the downloaded sample repository. + +| Platform | HyperExecute CLI | +| ---------| ---------------- | +| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute | +| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe | +| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute | + +### Step 3: Configyure `karate-config.js` file +This file defines runtime behaviors and integrates Karate with LambdaTest status reporting. + +```javascript +function fn() { + var lambdaHooks = function() { + if (karate.info.errorMessage) { + script('lambda-status=failed'); + } else { + script('lambda-status=passed'); + } + } + + var env = karate.env || 'dev'; + karate.log('karate.env:', env); + + var config = { + env: env, + hub: karate.properties['hub'] + }; + + karate.configure('afterScenario', lambdaHooks); + + return config; +} +``` + +:::note +- `lambdaHooks` sets test status based on execution outcome. +- `hub` is dynamically picked to support Selenium Grid for UI tests. +- Supports environment-based configuration using `karate.env`. +::: + + +### Step 4: Create your hyperexecute.yml file +The core of HyperExecute configuration lies in the `hyperexecute.yaml` file. Let’s break down the structure and understand each section: + +#### 1. Environment & Runtime Setup +This section specifies the OS, runtime language, concurrency, and autosplit features: + +```yaml +version: 0.1 +runson: linux # OS to run the tests (e.g., linux, win) +autosplit: true +concurrency: 2 # Defines the number of test sessions to run concurrently + +runtime: + language: java + version: 11 +``` + +#### 2. Dependency Resolution with Maven +Before running the actual performance test, ensure all project dependencies are resolved locally for a reproducible build. This step pulls all required Maven dependencies to a local directory (.m2), ensuring environment consistency. + +```yaml +pre: + - mvn -Dmaven.repo.local=./.m2 dependency:resolve +``` + +#### 3. Configure Test Discovery +Test discovery determines what files or test suites should be run. Use the [snooper](https://www.lambdatest.com/support/docs/hyperexecute-snooper/) utility to identify test files dynamically. + +```yaml +testDiscovery: + type: raw + mode: static + command: snooper --targetOs=win --featureFilePaths=src/test/java/app --frameWork=java | sed 's/:.*//' | uniq +``` + +> You can change discovery logic to run at the scenario, tag, or step definition level based on your need. + +#### 4. Configure the Test Execution Command +The execution command uses Maven and passes feature file paths from discovery: + +```yaml +testRunnerCommand: mvn test -Dtest=MyApiRunner -DFeaturePath="$test" -Dhub=https://LT_USERNAME:LT_ACCESS_KEY@hub.lambdatest.com/wd/hub -Dmaven.repo.local=./.m2 +``` + +Here is a complete working YAML configuration that runs Gatling performance tests on linux runners via HyperExecute: + +```yaml reference title="hyperexecute.yaml" +https://github.com/LambdaTest/hyperexecute-karate-sample/blob/main/HyperExecute.yaml +``` + +> 📘 For a deeper understanding and project-specific configurations, check out the [YAML documentation](https://www.lambdatest.com/support/docs/hyperexecute-yaml-parameters/). + +### Step 5: Execute your Test Suite +From the project root directory, execute the below CLI command in your terminal: + +
+ + {`./hyperexecute --user ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config hyperexecute.yaml`} + +
+ +> **NOTE :** In case of macOS, if you get a permission denied warning while executing CLI, simply run **`chmod u+x ./hyperexecute`** to allow permission. In case you get a security popup, allow it from your **System Preferences** → **Security & Privacy** → **General tab**. + +automation-dashboard + +## Advanced Parameters +Optimize your test pipeline using the following advanced features: + +- ✅ [Smart Test Splitting](/support/docs/hyperexecute-test-splitting-and-multiplexing/) – Automatically distribute tests across parallel runners +- ⚡ [Fail Fast](/support/docs/hyperexecute-failfast/) – Stop test runs on the first failure +- 📊 [Detailed Reports](/support/docs/hyperexecute-reports/) – Real-time terminal logs & rich test reports \ No newline at end of file diff --git a/docs/upload-files-using-lambdatest.md b/docs/upload-files-using-lambdatest.md index 312ac1a2a..9de10de71 100644 --- a/docs/upload-files-using-lambdatest.md +++ b/docs/upload-files-using-lambdatest.md @@ -55,15 +55,15 @@ You can upload the files on the LambdaTest cloud based Selenium Grid, using our * Click on the Lock icon to authorize your account. lock icon] * Enter your LambdaTest username and access key, in the box that appears, to validate your credentials. Once done, click on the "Authorise button to verify the credentials, and click on Close to close the window. authorize button -> -To get your LambdaTest Username and Access Key, visite your [LambdaTest automation dashboard](https://automation.lambdatest.com/) and click on the "key" icon, present on the top right corner. + +> To get your LambdaTest Username and Access Key, visite your [LambdaTest automation dashboard](https://automation.lambdatest.com/) and click on the "key" icon, present on the top right corner. automation key * Then click on the "Try it out" button. choose file * Once your authorization is successful and you click on the Try it out button, an option to select the file will appear on your screen. Choose the file to be uploaded using the "Choose File" button and click on Execute to upload it on the LambdaTest platform. 200 status code -> -**Note**: You can upload multiple files to our lambda storage. A maximum of 150 files can be uploaded per organization. We have limit of 20 MB files size per API. So if you are total file sizes reach the limit, please upload your files in multiple API calls. + +> **Note**: You can upload multiple files to our lambda storage. A maximum of 150 files can be uploaded per organization. We have limit of 20 MB files size per API. So if you are total file sizes reach the limit, please upload your files in multiple API calls. Once the file is successfully uploaded, you will see a response body with 200 response code, as shown in the image below: upload file @@ -169,7 +169,30 @@ For example, let's say you want to upload a file on a web page via test script, ``` * * * -> + +# Download Files from LambdaTest Storage while test execution + +During Selenium automation testing, there are scenarios where you need to retrieve files from LambdaTest's cloud storage directly to the machine running your test. LambdaTest provides a download hook that enables you to fetch files from lambda storage seamlessly during test execution. + + +Before using the download hook, ensure that: +- Files are already uploaded to LambdaTest storage using the [file upload API](https://www.lambdatest.com/support/api-doc/) +- You have the exact file names stored in lambda storage + +## Download Hook Implementation + +### Basic Syntax + +The download hook uses a simple executeScript command to fetch files from lambda storage: + +``` +driver.executeScript("lambda-files-download=file_name") +``` + + + +* * * + That's it! You can now successfully upload files and use them with Selenium Automation testing on LambdaTest's cloud server. If you face any issues, please feel free to reach out to us via our  window.openLTChatWidget()}>**24/7 chat support**, or you can even mail us at [support@lambdatest.com](mailto:support@lambdatest.com)
Happy Testing!