Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
206 changes: 206 additions & 0 deletions docs/hyperexecute-karate-testing.md
Original file line number Diff line number Diff line change
@@ -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';

<script type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify({
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.lambdatest.com"
},{
"@type": "ListItem",
"position": 2,
"name": "Support",
"item": "https://www.lambdatest.com/support/docs/"
},{
"@type": "ListItem",
"position": 3,
"name": "How to run automation tests on HyperExecute using Karate framework",
"item": "https://www.lambdatest.com/support/docs/hyperexecute-karate-testing/"
}]
})
}}
></script>
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.

<a href="https://github.com/LambdaTest/hyperexecute-karate-sample/" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
:::

### 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:

<div className="lambdatest__codeblock">
<CodeBlock className="language-bash">
{`./hyperexecute --user ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config hyperexecute.yaml`}
</CodeBlock>
</div>

> **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**.

<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/karate/karate.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>

## 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
33 changes: 28 additions & 5 deletions docs/upload-files-using-lambdatest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <img loading="lazy" src={require('../assets/images/uploads/upload-files-1.webp').default} alt="lock icon" width="1281" height="721" className="doc_img"/>]
* 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. <img loading="lazy" src={require('../assets/images/uploads/upload-files-2.webp').default} alt="authorize button" width="1281" height="722" className="doc_img"/>

>
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.
<img loading="lazy" src={require('../assets/images/uploads/access-key.webp').default} alt="automation key" width="1281" height="721" className="doc_img"/>

* Then click on the "Try it out" button. <img loading="lazy" src={require('../assets/images/uploads/upload-files-3.webp').default} alt="choose file" width="1281" height="721" className="doc_img"/>
* 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. <img loading="lazy" src={require('../assets/images/uploads/upload-files-4.webp').default} alt="200 status code" width="1281" height="721" className="doc_img"/>

>
**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: <img loading="lazy" src={require('../assets/images/uploads/upload-files-5.webp').default} alt="upload file" width="1281" height="721" className="doc_img"/>

Expand Down Expand Up @@ -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 <span className="doc__lt" onClick={() => window.openLTChatWidget()}>**24/7 chat support**</span>, or you can even mail us at [support@lambdatest.com](mailto:support@lambdatest.com) <br />Happy Testing!

<nav aria-label="breadcrumbs">
Expand Down
5 changes: 5 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ module.exports = {
label: "API Testing",
id: "hyperexecute-api-testing",
},
{
type: "doc",
label: "Karate",
id: "hyperexecute-karate-testing",
},
],
},
{
Expand Down
Loading