Skip to content

Commit fdb31df

Browse files
committed
add lambdatest example
1 parent 09e4fc4 commit fdb31df

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ This repository also contains examples of how to use Karate and demonstrates int
4040
* [GitHub Codespaces](https://github.com/karatelabs/karate/wiki/Get-Started:-GitHub-Codespaces) - open a GitHub project directly in a browser and run and edit Karate tests
4141
* [gRPC](grpc/README.md) - How to test gRPC services with Karate
4242
* [Gatling](https://github.com/karatelabs/karate/tree/master/karate-gatling) - Karate can re-use API functional tests as performance tests !
43-
* [Kafka](kafka/README.md) - Using the power of Karate Java interop to test Kafka and async flows
4443
* [JUnit](https://github.com/karatelabs/karate#junit-5) - There is also a [pure Java API](https://github.com/karatelabs/karate#parallel-execution) to run tests from any Java unit-testing framework such as TestNG
44+
* [Kafka](kafka/README.md) - Using the power of Karate Java interop to test Kafka and async flows
45+
* [Lambdatest](lambdatest/README.md) - How to configure Karate to run tests on Lambdatest
4546
* [NPM](https://github.com/karatelabs/karate-npm) - there is an option to install Karate as a NPM package and use it from Node / JS
4647
* [Quarkus](quarkus/README.md) - Karate is a good fit for integration testing Quarkus applications
4748
* [RabbitMQ](rabbitmq/README.md) - Using Java to send and receive messages with RabbitMQ
48-
* [Sauce Labs](sauce-labs/README.md) - How to configure Karate to run tests on Sauce Labs
49+
* [Sauce Labs](saucelabs/README.md) - How to configure Karate to run tests on Sauce Labs
4950
* [Spring Boot](spring-boot/README.md) - Resources on testing Spring Boot applications with Karate
5051
* [WebSockets](websockets/README.md) - Built-in support for WebSockets or you can use Java interop for very advanced scenarios
5152
* [Xray](https://docs.getxray.app/display/XRAYCLOUD/Testing+APIs+using+Karate+DSL) - Official documentation from the Xray team on how to integrate Karate

lambdatest/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Karate and Lambdatest
2+
3+
Karate supports the [W3C WebDriver protocol](https://www.w3.org/TR/webdriver) and can be used to run tests on [Lambdatest](https://www.lambdatest.com).
4+
5+
The [example in this folder](lambdatest.feature) demonstrates how to run a test on Lambdatest using Karate. All you need is a Lambdatest account and values such as the URL, user, key etc.
6+
7+
From your Lambdatest profile, you can get the values you need.
8+
9+
There may be differences such as needing the "username" and "accessKey" instead of the user details encoded in the URL.
10+
11+
All you need to do in Karate is perform the [`configure driver` step](https://github.com/karatelabs/karate/tree/master/karate-core/#configure-driver) as per the documentation. Note how `LT:Options` are added to the WebDriver "capabilities":
12+
13+
```cucumber
14+
* def session = { capabilities: { alwaysMatch: { browserName: 'chrome', browserVersion: 'latest', platformName: 'Windows 11', 'LT:Options': '#(lambdaTestOptions)' } } }
15+
* configure driver = { type: 'chromedriver', start: false, webDriverSession: '#(session)', webDriverUrl: '#(lambdaTestUrl)' }
16+
```
17+
18+
Of course you can change the `browserVersion` and `platformName` to suit your needs. You will have to ensure that the Karate driver type matches the `browserName`, for example `chromedriver` for `chrome`. Refer to the [Karate documentation](https://github.com/karatelabs/karate/tree/master/karate-core/#driver-types) for all possible types.
19+
20+
Also refer to the documentation of [`webDriverSession`](https://github.com/karatelabs/karate/tree/master/karate-core/#webdriversession) and [`webDriverUrl`](https://github.com/karatelabs/karate/tree/master/karate-core/#webdriverurl) for more details.
21+
22+
Note that for a typical test-suite, you will set variables via the [`karate-config.js`](https://github.com/karatelabs/karate/#karate-configjs) so you can switch browsers or between local and remote execution.
23+
24+
## Further Reading
25+
26+
* [Karate and Lambdatest on Stack Overflow](https://stackoverflow.com/search?q=%5Bkarate%5D+lambdatest)
27+
* [Running UI Tests in parallel](https://stackoverflow.com/a/60387907/143475)
28+
29+
30+
31+
32+

lambdatest/lambdatest.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: lambdatest automation demo
2+
3+
Background:
4+
# enter the values for the next few lines from your lambatest account
5+
* def lambdaTestUser = ''
6+
* def lambdaTestKey = ''
7+
* def lambdaTestUrl = 'https://hub.lambdatest.com/wd/hub'
8+
* def lambdaTestOptions = { project: '#(karate.feature.prefixedPath)', username: '#(lambdaTestUser)', accessKey: '#(lambdaTestKey)' }
9+
* def session = { capabilities: { alwaysMatch: { browserName: 'chrome', browserVersion: 'latest', platformName: 'Windows 11', 'LT:Options': '#(lambdaTestOptions)' } } }
10+
* configure driver = { type: 'chromedriver', start: false, webDriverSession: '#(session)', webDriverUrl: '#(lambdaTestUrl)' }
11+
12+
Scenario: try to login to github and check for expected error message
13+
* driver 'https://github.com/login'
14+
* input('#login_field', 'XXXX')
15+
* input('#password', 'world')
16+
* submit().click("input[name=commit]")
17+
* match html('.flash-error') contains 'Incorrect username or password.'

sauce-labs/README.md renamed to saucelabs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Karate and Sauce Labs
22

3-
Karate supports the [W3C WebDriver protocol](https://www.w3.org/TR/webdriver) and can be used to run tests on Sauce Labs.
3+
Karate supports the [W3C WebDriver protocol](https://www.w3.org/TR/webdriver) and can be used to run tests on [Sauce Labs](https://saucelabs.com).
44

5-
The [example in this folder](sauce-labs.feature) demonstrates how to run a test on Sauce Labs using Karate. All you need is a Sauce Labs account and the values of the Sauce Labs "build" and the URL to connect to.
5+
The [example in this folder](saucelabs.feature) demonstrates how to run a test on Sauce Labs using Karate. All you need is a Sauce Labs account and values such as the URL, user, key etc.
66

77
From your Sauce Labs dashboard, you can get the values you need from the quickstart guide for Selenium / Java. Here is a screenshot showing which sections you can focus on:
88

sauce-labs/sauce-labs.feature renamed to saucelabs/saucelabs.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: sauce labs automation demo
22

33
Background:
4-
# enter the values for the next 2 lines from your sauce labs account
4+
# enter the values for the next few lines from your sauce labs account
55
* def sauceLabsBuild = ''
66
* def sauceLabsUser = ''
77
* def sauceLabsKey = ''

0 commit comments

Comments
 (0)