You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/java-frameworks.md
-7Lines changed: 0 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,14 +70,7 @@ cd java-selenium-sample
70
70
If you are using your own project, make sure you update the **Hub endpoint** in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution.
@@ -45,198 +47,112 @@ import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/co
45
47
})
46
48
}}
47
49
></script>
50
+
This guide walks you through the process of running Selenium TestNG tests on LambdaTest, a cloud-based cross-browser testing platform. By following these steps, you can seamlessly execute automated tests on a wide range of browsers and operating systems using LambdaTest’s Selenium Grid.
48
51
49
-
import Tabs from '@theme/Tabs';
50
-
import TabItem from '@theme/TabItem';
51
-
52
-
# Selenium With TestNG Tutorial
53
-
54
-
---
55
-
56
-
In this topic, you will learn how to configure and run tests using **TestNG** on LambdaTest's [Selenium testing cloud platform](https://www.lambdatest.com/selenium-automation).
57
-
58
-
## Objectives
59
-
60
-
---
52
+
## Prerequisites
53
+
Before you begin, ensure you have the following:
61
54
62
-
By the end of this topic, you will be able to:
55
+
- Your [LambdaTest Username and Access Key](https://accounts.lambdatest.com/)
56
+
- Install Java Development Kit (JDK). We recommend Java version 11
57
+
- Install [Maven](https://maven.apache.org/)
58
+
-[Download](https://www.selenium.dev/downloads/) the latest Selenium Client and its WebDriver bindings
63
59
64
-
1. Set up an environment for testing your hosted web pages using **TestNG** framework with **Selenium**.
65
-
2. Understand and configure the core capabilities required for your Selenium test suite.
66
-
3. Run test cases in parallel using **TestNG** with Selenium to reduce build times.
67
-
4. Test your locally hosted pages on LambdaTest platform.
68
-
5. Explore advanced features of LambdaTest.
60
+
## Step 1: Configure your test suite
69
61
70
62
:::tip Sample repo
63
+
Download or Clone the code sample for the TestNG from the LambdaTest GitHub repository to run the tests on our Standard Grid.
71
64
72
-
All the code samples in this documentation can be found on **LambdaTest's Github Repository**. You can either download or clone the repository to quickly run your tests. <ahref="https://github.com/LambdaTest/Java-TestNG-Selenium"className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
73
-
65
+
<ahref="https://github.com/LambdaTest/Java-TestNG-Selenium"className="github__anchor"target="_blank"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
74
66
:::
75
67
76
-
## Prerequisites
77
-
78
-
---
79
-
80
-
Before you can start performing Java automation testing with Selenium, you would need to:
81
-
82
-
- Install the latest **Java development environment**. We recommend to use **Java 11** version.
83
-
84
-
- Download the latest **Selenium Client** and its **WebDriver bindings** from the [official website](https://www.selenium.dev/downloads/). Latest versions of Selenium Client and WebDriver are ideal for running your automation script on LambdaTest Selenium cloud grid.
85
-
86
-
- Install **Maven** which supports **TestNG** framework out of the box. **Maven** can be downloaded and installed following the steps from [the official website](https://maven.apache.org/). Maven can also be installed easily on **Linux/MacOS** using [**Homebrew**](https://brew.sh/) package manager.
87
-
88
-
### Cloning Repo and Installing Dependencies
89
-
90
-
**Step 1:** Clone the LambdaTest’s [Java-TestNG-Selenium](https://github.com/LambdaTest/Java-TestNG-Selenium) repository and navigate to the code directory as shown below:
You may also want to run the command below to check for outdated dependencies.
73
+
If you are using your own project, make sure you update the **Hub endpoint** in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution.
Run the command below to check for outdated dependencies. Review updates carefully before modifying your `pom.xml`, as they might not be compatible with your code.
98
81
99
82
```bash
100
83
mvn versions:display-dependency-updates
101
84
```
102
85
103
-
### Setting up your Authentication
86
+
## Step 3: Configure your test Capabilities
87
+
LambdaTest requires specific capabilities to set the browser, browser version, operating system, and other configurations for your test.
104
88
105
-
Make sure you have your LambdaTest credentials with you to run test automation scripts on LambdaTest Selenium Grid. You can obtain these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build) or through [LambdaTest Profile](https://accounts.lambdatest.com/login).
89
+
Example desired capabilities for testing on Chrome 120:
106
90
107
-
**Step 2:** Set LambdaTest **Username** and **Access Key** in environment variables.
You can generate capabilities for your test requirements with the help of our inbuilt :link:**[Capabilities Generator tool](https://www.lambdatest.com/capabilities-generator/)**.
102
+
:::
110
103
111
-
<TabItemvalue="bash"label="Linux / MacOS"default>
104
+
## Step 4: Setup your LambdaTest credentials
105
+
In your terminal (as per your respective Operating System), run these command to setup your LambdaTest credentials.
106
+
> You can see your credentials below if you have logged into our platform.
**Step 3:** In the test script, you need to update your test capabilities. In this code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object. The capabilities object in the above code are defined as:
> You can also use **dev** and **beta** browser versions. To generate capabilities for your test requirements, you can use our inbuilt 🔗 [Capabilities Generator Tool](https://www.lambdatest.com/capabilities-generator/).
216
-
217
-
### Executing the Test
218
-
219
-
**Step 4:** The tests can be executed in the terminal using the following command.
220
-
221
137
```bash
222
138
mvn test -D suite=single.xml
223
139
```
140
+
</TabItem>
224
141
225
-
:::info
226
-
227
-
Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on [LambdaTest automation dashboard](https://accounts.lambdatest.com/login). LambdaTest Automation Dashboard will help you view all your text logs, screenshots and video recording for your entire automation tests.
Here is an example `xml` file which would help you to run a single test on various browsers at the same time, you would also need to generate a testcase which makes use of **TestNG** framework parameters (`org.testng.annotations.Parameters`).
152
+
<TabItemvalue="single-parallel"label="Single test on multiple browsers"default>
153
+
Here is an example xml file which would help you to run a single test on various browsers at the same time:
238
154
239
-
```xml title="testng.xml"
155
+
```xml
240
156
<?xml version="1.0" encoding="UTF-8"?>
241
157
<!DOCTYPEsuite SYSTEM "http://testng.org/testng-1.0.dtd">
@@ -269,93 +185,14 @@ Here is an example `xml` file which would help you to run a single test on vario
269
185
270
186
</suite>
271
187
```
188
+
</TabItem>
272
189
273
-
### Executing Parallel Tests using TestNG
274
-
275
-
To run parallel tests using **TestNG**, we would have to execute the below commands in the terminal:
276
-
277
-
- For the above example code
278
-
```bash
279
-
mvn test
280
-
```
281
-
- For the cloned Java-TestNG-Selenium repo used to run our first sample test
282
-
```bash
283
-
mvn test -D suite=parallel.xml
284
-
```
285
-
286
-
:::info
287
-
288
-
Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on [LambdaTest automation dashboard](https://accounts.lambdatest.com/login).
289
-
290
-
:::
291
-
292
-
## Testing Locally Hosted or Privately Hosted Projects
293
-
294
-
---
295
-
296
-
You can test your locally hosted or privately hosted projects with [LambdaTest Selenium grid cloud](https://www.lambdatest.com/selenium-automation) using LambdaTest Tunnel app. All you would have to do is set up an SSH tunnel using LambdaTest Tunnel app and pass toggle `tunnel = True` via desired capabilities. LambdaTest Tunnel establishes a secure SSH protocol based tunnel that allows you in testing your locally hosted or privately hosted pages, even before they are made live.
297
-
298
-
:::tip Tunnel Help
299
-
300
-
Refer our :link:[LambdaTest Tunnel documentation](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) for more information.
301
-
302
-
:::
303
-
304
-
Here’s how you can establish LambdaTest Tunnel.
305
-
306
-
:::info Download the binary file
307
-
308
-
-[LambdaTest Tunnel for Windows](https://downloads.lambdatest.com/tunnel/v3/windows/64bit/LT_Windows.zip)
309
-
-[LambdaTest Tunnel for Mac](https://downloads.lambdatest.com/tunnel/v3/mac/64bit/LT_Mac.zip)
310
-
-[LambdaTest Tunnel for Linux](https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip)
311
-
312
-
:::
313
-
314
-
Open command prompt and navigate to the binary folder.
0 commit comments