0

I have to integrate Gherkin with Katalon Studio, so I created a test project in Groovy with a basic scenario and imported the project in Katalon Studio. When I execute the Junit test in Katalon Studio it throws the error: "An internal error occurred during: "Launching TestGroovy". java.lang.NullPointerException". I have already added the necessary libraries.

Note: The test passes successfully in Eclipse.

What is the extra thing needed to run a Junit test on Katalon?

TestGroovy.groovy

package groovyKat

import org.junit.runner.RunWith
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "Features"
        ,glue= ["groovyKat"]
        )
class TestGroovy {

}

TestGroovyStepDef.groovy

package groovyKat

import java.util.concurrent.TimeUnit

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver

import cucumber.api.java.en.Given
import cucumber.api.java.en.Then
import cucumber.api.java.en.When


class TestGroovyStepDef {
    static WebDriver driver;
    @Given('^A User is on Demoqa\\.com$')
     void a_User_is_on_Demoqa_com() throws Throwable {
        System.setProperty('webdriver.gecko.driver','D:/geckodriver/geckodriver.exe');
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get('http://www.store.demoqa.com');
        }

    @When('^User clicks on MyAccount link$')
     void user_Clicks_on_MyAccount_link() throws Throwable {
        driver.findElement(By.xpath('.//*[@id="account"]/a')).click();
        }

    @When('^User enters username "(.*)" and password "(.*)"$')
     void user_enters_username_and_password(String username,String password) throws Throwable {
        driver.findElement(By.id('log')).sendKeys(username);     
        driver.findElement(By.id('pwd')).sendKeys(password);
        driver.findElement(By.id('login')).click();
        }

    @Then('^Message displayed Login Successfully$')
     void message_displayed_Login_Successfully() throws Throwable {
        System.out.println('Login Successfully');
    }
}

testSample.feature

Feature: Login feature

Scenario: Successful Login with Valid Credentials
          Given A User is on Demoqa.com
          When User clicks on MyAccount link
          And User enters username "xxxxxx" and password "xxxxxxx"
          Then Message displayed Login Successfully
Divya Nair
  • 39
  • 4

1 Answers1

1

With current version of Katalon (5.4.1) it is not possible to run this script, that is implemented as JUnit(Cucumber)-Test.

You have to rewrite your test for Katalon Studio.

See https://forum.katalon.com/discussion/1976/how-can-i-import-selenium-scripts-in-katalon

JanZ
  • 584
  • 2
  • 13