Skip to content

Commit c40da7e

Browse files
Merge pull request #1795 from amanchopra1905/stage
hyperexecute karate framework
2 parents 5949452 + 5640e6b commit c40da7e

File tree

4 files changed

+239
-5
lines changed

4 files changed

+239
-5
lines changed
99 KB
Loading
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
id: hyperexecute-karate-testing
3+
title: Karate Automation on HyperExecute
4+
hide_title: false
5+
sidebar_label: Karate
6+
description: Learn how to run Selenium automation tests on HyperExecute using the Karate framework
7+
keywords:
8+
- Karate
9+
- Karate selenium
10+
- Karate Java Selenium
11+
- Karate automation testing
12+
- selenium webdriver Karate
13+
- selenium Karate testing tutorial
14+
- Karate Java Selenium framework
15+
- lambdatest Karate
16+
- frameworks on lambdatest
17+
- hyperexecute
18+
- hyperexecute Karate testing
19+
- hyperexecute Karate testing
20+
- hyperexecute automation testing
21+
- HyperExecute Selenium automation
22+
url: https://www.lambdatest.com/support/docs/hyperexecute-karate-testing/
23+
site_name: LambdaTest
24+
slug: hyperexecute-karate-testing/
25+
---
26+
27+
import CodeBlock from '@theme/CodeBlock';
28+
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
29+
import Tabs from '@theme/Tabs';
30+
import TabItem from '@theme/TabItem';
31+
32+
<script type="application/ld+json"
33+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
34+
"@context": "https://schema.org",
35+
"@type": "BreadcrumbList",
36+
"itemListElement": [{
37+
"@type": "ListItem",
38+
"position": 1,
39+
"name": "Home",
40+
"item": "https://www.lambdatest.com"
41+
},{
42+
"@type": "ListItem",
43+
"position": 2,
44+
"name": "Support",
45+
"item": "https://www.lambdatest.com/support/docs/"
46+
},{
47+
"@type": "ListItem",
48+
"position": 3,
49+
"name": "How to run automation tests on HyperExecute using Karate framework",
50+
"item": "https://www.lambdatest.com/support/docs/hyperexecute-karate-testing/"
51+
}]
52+
})
53+
}}
54+
></script>
55+
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.
56+
57+
## 🚀 Why choose HyperExecute for Karate Testing?
58+
While Gatling is powerful on its own, running large-scale performance tests using traditional setups often introduces significant bottlenecks:
59+
60+
### ⚠️ Challenges with Traditional Runners
61+
- **Limited Parallelism:** Local runners struggle to scale effectively across multiple CPU cores or nodes.
62+
- **Environment Inconsistencies:** Variations in environments lead to flaky tests and hard-to-reproduce bugs.
63+
- **Manual Test Orchestration:** Managing dependencies, execution order, and reporting manually is error-prone.
64+
- **Lack of Observability:** Debugging failures can be slow due to scattered logs and minimal visibility.
65+
66+
### ✅ How HyperExecute Enhances Karate Testing
67+
LambdaTest’s HyperExecute platform eliminates these issues with a modern, cloud-native test runner that offers:
68+
69+
- **⚡ Smart Test Distribution:** HyperExecute auto-splits Karate feature files across multiple nodes to optimize execution speed.
70+
- **🔒 Isolated Test Environments:** Each test job runs in a clean, sandboxed environment with controlled dependencies.
71+
- **📦 Seamless Artifact Upload:** Automatically captures and uploads Karate test reports for easier analysis.
72+
- **🔁 Built-in Retries & Stability Handling:** Reduce flakiness with automatic retries for failed test jobs.
73+
- **📈 Unified Dashboard & Logs:** Get centralized access to logs, artifacts, and test metadata for efficient debugging.
74+
75+
## Prerequisites
76+
To run the Tests on HyperExecute from your Local System, you are required:
77+
78+
- Your LambdaTest [Username and Access key](https://www.lambdatest.com/support/docs/hyperexecute-how-to-get-my-username-and-access-key/)
79+
- [HyperExecute YAML](https://www.lambdatest.com/support/docs/hyperexecute-yaml-version0.2/) file which contains all the necessary instructions.
80+
- [HyperExecute CLI](https://www.lambdatest.com/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/) in order to initiate a test execution Job .
81+
- Setup the [Environmental Variable](https://www.lambdatest.com/support/docs/hyperexecute-environment-variable-setup/)
82+
83+
## Run a Sample Project
84+
### Step 1: Download Project
85+
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
86+
87+
:::tip Sample repo
88+
Download or Clone the code sample for the Karate from the LambdaTest GitHub repository to run the tests on the HyperExecute.
89+
90+
<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>
91+
:::
92+
93+
### Step 2: Download the CLI in your Project
94+
Download the HyperExecute CLI and copy it into the root folder of the downloaded sample repository.
95+
96+
| Platform | HyperExecute CLI |
97+
| ---------| ---------------- |
98+
| Linux | https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute |
99+
| Windows | https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe |
100+
| macOS | https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute |
101+
102+
### Step 3: Configyure `karate-config.js` file
103+
This file defines runtime behaviors and integrates Karate with LambdaTest status reporting.
104+
105+
```javascript
106+
function fn() {
107+
var lambdaHooks = function() {
108+
if (karate.info.errorMessage) {
109+
script('lambda-status=failed');
110+
} else {
111+
script('lambda-status=passed');
112+
}
113+
}
114+
115+
var env = karate.env || 'dev';
116+
karate.log('karate.env:', env);
117+
118+
var config = {
119+
env: env,
120+
hub: karate.properties['hub']
121+
};
122+
123+
karate.configure('afterScenario', lambdaHooks);
124+
125+
return config;
126+
}
127+
```
128+
129+
:::note
130+
- `lambdaHooks` sets test status based on execution outcome.
131+
- `hub` is dynamically picked to support Selenium Grid for UI tests.
132+
- Supports environment-based configuration using `karate.env`.
133+
:::
134+
135+
136+
### Step 4: Create your hyperexecute.yml file
137+
The core of HyperExecute configuration lies in the `hyperexecute.yaml` file. Let’s break down the structure and understand each section:
138+
139+
#### 1. Environment & Runtime Setup
140+
This section specifies the OS, runtime language, concurrency, and autosplit features:
141+
142+
```yaml
143+
version: 0.1
144+
runson: linux # OS to run the tests (e.g., linux, win)
145+
autosplit: true
146+
concurrency: 2 # Defines the number of test sessions to run concurrently
147+
148+
runtime:
149+
language: java
150+
version: 11
151+
```
152+
153+
#### 2. Dependency Resolution with Maven
154+
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.
155+
156+
```yaml
157+
pre:
158+
- mvn -Dmaven.repo.local=./.m2 dependency:resolve
159+
```
160+
161+
#### 3. Configure Test Discovery
162+
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.
163+
164+
```yaml
165+
testDiscovery:
166+
type: raw
167+
mode: static
168+
command: snooper --targetOs=win --featureFilePaths=src/test/java/app --frameWork=java | sed 's/:.*//' | uniq
169+
```
170+
171+
> You can change discovery logic to run at the scenario, tag, or step definition level based on your need.
172+
173+
#### 4. Configure the Test Execution Command
174+
The execution command uses Maven and passes feature file paths from discovery:
175+
176+
```yaml
177+
testRunnerCommand: mvn test -Dtest=MyApiRunner -DFeaturePath="$test" -Dhub=https://LT_USERNAME:LT_ACCESS_KEY@hub.lambdatest.com/wd/hub -Dmaven.repo.local=./.m2
178+
```
179+
180+
Here is a complete working YAML configuration that runs Gatling performance tests on linux runners via HyperExecute:
181+
182+
```yaml reference title="hyperexecute.yaml"
183+
https://github.com/LambdaTest/hyperexecute-karate-sample/blob/main/HyperExecute.yaml
184+
```
185+
186+
> 📘 For a deeper understanding and project-specific configurations, check out the [YAML documentation](https://www.lambdatest.com/support/docs/hyperexecute-yaml-parameters/).
187+
188+
### Step 5: Execute your Test Suite
189+
From the project root directory, execute the below CLI command in your terminal:
190+
191+
<div className="lambdatest__codeblock">
192+
<CodeBlock className="language-bash">
193+
{`./hyperexecute --user ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config hyperexecute.yaml`}
194+
</CodeBlock>
195+
</div>
196+
197+
> **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**.
198+
199+
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/karate/karate.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>
200+
201+
## Advanced Parameters
202+
Optimize your test pipeline using the following advanced features:
203+
204+
-[Smart Test Splitting](/support/docs/hyperexecute-test-splitting-and-multiplexing/) – Automatically distribute tests across parallel runners
205+
-[Fail Fast](/support/docs/hyperexecute-failfast/) – Stop test runs on the first failure
206+
- 📊 [Detailed Reports](/support/docs/hyperexecute-reports/) – Real-time terminal logs & rich test reports

docs/upload-files-using-lambdatest.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ You can upload the files on the LambdaTest cloud based Selenium Grid, using our
5555
* 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"/>]
5656
* 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"/>
5757

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

65-
>
66-
**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.
65+
66+
> **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.
6767
6868
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"/>
6969

@@ -169,7 +169,30 @@ For example, let's say you want to upload a file on a web page via test script,
169169
```
170170

171171
* * *
172-
>
172+
173+
# Download Files from LambdaTest Storage while test execution
174+
175+
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.
176+
177+
178+
Before using the download hook, ensure that:
179+
- Files are already uploaded to LambdaTest storage using the [file upload API](https://www.lambdatest.com/support/api-doc/)
180+
- You have the exact file names stored in lambda storage
181+
182+
## Download Hook Implementation
183+
184+
### Basic Syntax
185+
186+
The download hook uses a simple executeScript command to fetch files from lambda storage:
187+
188+
```
189+
driver.executeScript("lambda-files-download=file_name")
190+
```
191+
192+
193+
194+
* * *
195+
173196
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!
174197

175198
<nav aria-label="breadcrumbs">

sidebars.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ module.exports = {
375375
label: "API Testing",
376376
id: "hyperexecute-api-testing",
377377
},
378+
{
379+
type: "doc",
380+
label: "Karate",
381+
id: "hyperexecute-karate-testing",
382+
},
378383
],
379384
},
380385
{

0 commit comments

Comments
 (0)