Is it possible to run a Cucumber Test with just one command, depending on the tags condition? For example, only execute the @Regression tag if the @sm

I am currently facing a need to develop a single run command or script file that can execute the @Smoke tag test first, and if it passes, continue on to execute the @Regression tag. If the Smoke test fails, then the execution should be aborted.

We are working with a BDD setup using Cucumber, Selenium, and Java within a Maven project. Can this requirement be achieved?

Answer №1

If you are working with Cucumber along with JUnit 5, then the JUnit Platform Launcher API can be utilized to execute your tests programmatically.

public class RunCucumber {

   public static void main(String[] args) {

      LauncherDiscoveryRequest request = request()
              .selectors(
                      selectDirectory("path/to/features")
              )
              .filters(
                      includeTags("Smoke"),
              )
              .build();

      Launcher launcher = LauncherFactory.create();
      SummaryGeneratingListener listener = new SummaryGeneratingListener();
      launcher.registerTestExecutionListeners(listener);
      launcher.execute(request);

      TestExecutionSummary summary = listener.getSummary();
      // Perform further actions with the summary

      // Repeat the process for regression tests if necessary.
   }

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In the W3C WebDriver's "Locate Element Within Element" command, what is the correct way to structure the element ID within the request URL?

Trying to wrap my head around how a WebDriver functions, but struggling with formatting the request URL for Find Element From Element. When obtaining the element ID from Find Element, it appears like this: {"element-6066-11e4-a52e-4f735466cecf": ...

An error in the Generic Device Interface Plus (GDI+) framework occurred while attempting to capture a

An unexpected GDI+ error occurred while trying to capture a screenshot. Despite having write access to the folder, I am puzzled as to why this error is happening. Below is the code that is causing the issue: driver = new FirefoxDriver(); string ba ...

Exploring with Selenium in Python to identify when a CSS attribute is defined with a specific value

Is it possible to use Selenium to check if the 'cursor' property is set to 'auto' or 'zoom-in'? In my program, I have a list of 10 product links and need to open each one in a loop. I want to identify links where the image ha ...

Caution in Ruby Selenium: The use of :driver_path is no longer supported

I have been using Ruby selenium-webdriver version 3.142.6 for my tests, and they are functioning properly. However, a warning message appears at the beginning of the test run. WARN Selenium [DEPRECATION] :driver_path is deprecated. Use :service with an in ...

Having trouble with selecting multiple checkboxes with Selenium Webdriver

My goal is to select all 50 items on each page. Here's the code I'm using: wait = WebDriverWait(browser, 10) element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="results-list-delivery-toolbar"]/div/ul[1]/li[4]/ul/li[3]/but ...

How can one use C# and Selenium to send text to a hidden textarea with the attribute style="display: none;"?

I'm encountering an issue where I am unable to write in the textarea using the sendkeys function in Selenium. The specific textarea I am trying to target has an ID of 'txtSkillsTaught-Value' and is located after a script tag that seems to be ...

Having trouble importing Selenium in my VSCode environment, despite having both Python and pip successfully installed

Despite having Python and pip installed correctly, I am encountering an error when trying to import selenium. Both the command prompt and VSCode acknowledge that Python is installed, yet the error persists. I am unsure of what step I am missing. Can anyo ...

Ensure that the page has completely loaded using WebdriverJS

Is there a reliable method to ensure that a page has fully loaded using selenium-webdriver in JavaScript? I came across this similar query, but I require an implementation specifically in JavaScript. var webdriver = require('selenium-webdriver') ...

The designated element in Python Selenium cannot be found

Having trouble clicking on a specific nested li in a ul. Every time I try, an error occurs. I have attempted to use xpath but any other suggestions would be appreciated. Keep in mind that there is additional text after the span tag. Here is the script: ...

Difficulty in Identifying Accept Button using Python and Selenium

Having trouble selecting the okay button from an alert message in a new window. I'm not sure what's going wrong but I just need to accept the alert to complete the removal process. You can find the script code here: https://github.com/Richard-Bar ...

Tips for choosing an element using a reference element in Selenium WebDriver

As someone who is new to selenium automation, I have encountered a scenario where I need to click on a button based on a specific title. However, the button element appears the same for all rows in the table. This is what it looks like: Here's the HT ...

Finding and saving several elements using selenium

In my current project, I am trying to locate and save the positions of certain elements so that a bot can click on them even if the page undergoes changes. While researching online, I found suggestions that storing the location of a single element in a var ...

The partnership between Selenium and WhitePages has created an innovative solution

I am currently attempting to register on . The registration process requires entering my first name, last name, email address, and password. For the first name field, I attempted to locate the element by CSS using the syntax "input#name_fname", however, I ...

TimeoutException occurred while running parallel test scenarios on Selenium Grid hosted in Docker container

Our Automation project is developed in Java and relies on the following libraries: Cucumber 3.1.6 Selenium 4.0.0 awaitility 3.1.6 We run multiple Jenkins jobs concurrently in a Selenium Grid Docker setup: version 4.7.2 with a Hub and Chrome node configurat ...

Extracting data from a Bid and Ask section on a trading platform's webpage

I am struggling with extracting prices from the Bid and Ask columns on this specific website: [https://banggia.vps.com.vn/chung-khoan/derivative-VN30][1]. Currently, I am only able to extract the class name which is "price-table-content". How can I modify ...

Is there a way to simulate pressing arrow keys randomly using Selenium in Python?

My current project involves creating a program that can play the game 2048 by randomly choosing arrow keys. I attempted the following code snippet: moves = [htmlElem.send_keys(Keys.UP),htmlElem.send_keys(Keys.RIGHT),htmlElem.send_keys(Keys.DOWN),htmlEle ...

Initialization of the page factory

I have successfully implemented a framework using the POM and Page Factory approach. In my baseTest class, I have multiple initializations such as: Registration regPage = PageFactory.initelements(driver, Registration.class); Login loginPage = PageFactory. ...

Is there any other option in Robot Framework besides Selenium2Library's "Input Text" for inputting text into text fields?

My current challenge lies with the Selenium2Library "Input Text" keyword because of a specific auto-formatting script in newly added text fields. This script seems to be causing issues when entering text using the keyword, as it inserts spaces after a cert ...

Leveraging a custom initializer with Selenium in .Net Core 2 to utilize FindsBy without relying on PageFactory

My question is a bit more complex. Can the C# Selenium [FindsBy(.....)] be used with a custom initializer? I am aware that the PageFactory has been removed and wouldn't work the way I need it to, as I want the initializer to perform its job when the ...

Selenium WebDriver can be used to choose a checkbox by selecting

Hello, I am facing an issue where I need to select checkboxes that have the same IDs. Below is the HTML code snippet: <label class="table-checkbox-label" for="record-12034"> <input id="record-12034" class="table-checkbox" type="checkbox"/> < ...