LambdaTest allows you to group your automation tests using custom tags. In this document, we will see how to create custom tags and use them. For demonstration purposes, we have used a sample TestNG script to run on the LambdaTest platform.
You can create a custom tag using a simple step. While writing your Selenium automation tests, when you create the Desired Capabilities via code, just add the below lines of code.
Create a String array that contains the names of your custom tags, separated by a comma.
1 2 3 4 5 |
// In case for just 1 tag, just add 1 element in the array String[] customTags = {"Custom Tag"}; // In case for multiple tags, add them in the array separated by comma String[] customTags = {"Tag 1", "Tag 2", "Tag 3", ...}; |
Now you just need to add this custom tag in your Desired Capabilities instance, as shown below:
1 2 3 4 5 6 |
DesiredCapabilities caps = new DesiredCapabilities(); . . // To create custom tags caps.setCapability("tags", customTags); |
For example:
You have successfully created the custom tags. Let’s now see how to view the custom tags and how to group the test based on custom tags in the below section.
There are multiple ways by which you can view the custom tags in the automation dashboard, such as Timeline view and Automation logs view. We will see one by one, how to view the custom tags in each of these.
Navigate to Timeline view of your automation dashboard, and toggle the Build View to Test View, as shown in the image below:
You can see the applied custom tags below the tests in this Test View.
Navigate to Automation Logs of your automation dashboard, and you can see the applied custom tags below the tests in the left panel.
You can also filter the tests on your automation dashboard with the help of these custom tags. Let us see how.
Navigate to Automation Logs of your automation dashboard, and you can see a filter by name Tags in the filter toolbar.
Click on it and select the Tag by which you want to filter the tests on your dashboard. For example, we have filtered the test using Tag2 custom tag, as shown in the image below:
You can even filter the tests by selecting multiple custom tags at once, from the filter toolbar, as shown in the image below:
Kudos! You have successfully created a custom tag and grouped your tests based on the custom tag. If you still have any questions, feel free to share them with us through our 24/7 chat support or by mailing to us on support@lambdatest.com. Happy testing! 🙂