pridhvimallikharjun
pridhvimallikharjun

Reputation: 29

Browser not opening when executing cucumber script but script passed

I have created a simple feature which just should launch a browser, however, the browser not launching and script shows pass in console.

Feature file

Feature: Flipkart home page

Scenario: Test Given launch browser

StepDefinition

package stepDefinitions;

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;

import io.cucumber.java.en.Given; import io.github.bonigarcia.wdm.WebDriverManager;

public class HomeStepDefinition {

public WebDriver driver;

@Given("^launch browser$")
public void launch_browser() {
WebDriverManager.chromedriver().setup();
    driver = new ChromeDriver();
    System.out.println("test");
    
    
}

}

TestRunner

    package testRunner;

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;

@CucumberOptions(features ="src/test/java/features/Home.feature",glue="stepDefinitions",monochrome=true,dryRun=true)
public class TestRunner extends AbstractTestNGCucumberTests{

}

Output

[RemoteTestNG] detected TestNG version 7.8.0 SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. PASSED: io.cucumber.testng.AbstractTestNGCucumberTests.runScenario("Test", "Flipkart home page") Runs Cucumber Scenarios

=============================================== Default test Tests run: 1, Failures: 0, Skips: 0

=============================================== Default suite Total tests run: 1, Passes: 1, Failures: 0, Skips: 0

Upvotes: 0

Views: 142

Answers (1)

sashkins
sashkins

Reputation: 931

In your TestRunner you should remove the dryRun @CucumberOptions parameter, or change its value to 'false' (which is the default one).

When you set dryRun to true it will simply scan over all your features to check whether all used steps are available in the 'glue', so it won't execute the actual steps.

You can check the descriptions of different cucumber options here

Upvotes: 0

Related Questions