Cucumber : NullPointerException

Hi!
I’m trying to use Cucumber and testng to run my tests but I’m getting this NullPointerException error:
java.lang.NullPointerException
at tessi.cheqcorner.StepDefinitionImp.je_midentifie_en_mode_iban(StepDefinitionImp.java:22)
at ✽.Je m’identfie en mode IBAN(file:///C:/Users/wmejri/Desktop/CheqCornerAppium/src/test/java/cucumber/IBAN/iban.feature:8)

:dizzy:My BaseTest.java file:
package tessi.cheqcorner;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import org.testng.annotations.BeforeClass;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class BaseTest {
public AndroidDriver driver;
public IdentificationPage idPage;

@BeforeClass
public void AppiumTest() throws MalformedURLException {

    UiAutomator2Options options = new UiAutomator2Options();
    options.setDeviceName("13.5 Freeform API 30"); //13.5 Freeform API 30
    options.setAutoGrantPermissions(true);
    options.setAppWaitForLaunch(false);
    options.setApp("C:\\Users\\wmejri\\Desktop\\CheqCornerAppium\\src\\test\\ressources\\rc13(1).apk");

    driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), options);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    idPage = new IdentificationPage(driver);

}

}

:dizzy:My iban.feature file:

  @Tag
    Feature: Identification en mode IBAN et dépôt des chèques bancaires

      @tag2:
      Scenario Outline: Test positive d'identification avec IBAN et dépot d'un nombre de chèques inférieur au grand remettant

        Given Je m'identfie en mode IBAN

        When Je peux remettre <nombre de chèques> chèques
        Then Je peux valider le montant des chèques
        And Je vois la page qui m'informe que l'opération est réussie

        Examples:
          | nombre de chèques |
          | 1                 |
          | 2                 |
          | 3                 |
          | 4                 |

:dizzy:My TestNGTestRunner file :

package cucumber.IBAN;

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

@CucumberOptions(features = “src/test/java/cucumber/IBAN”, glue=“tessi/cheqcorner”, monochrome=true, plugin = {“html:target/cucumber.html”})
public class TestNGTestRunner extends AbstractTestNGCucumberTests {

}

:dizzy:My StepDefinitionImp.java file :
package tessi.cheqcorner;

import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.testng.Assert;

public class StepDefinitionImp extends BaseTest {
public DeliveryOfChecksPage deliveryPage;
public SumPage sumPage;

@Given("Naviguer vers le page d'identification")
public void naviguer_vers_la_page_didentification() {
    idPage.clickDialServerValidBtn(); //Cliquer sur le bouton valider du choix de serveur
    idPage.clickBtnConfirm(); //Confirmer la licence Knox
    idPage.clickBtnOtouchMainlyout(); //Cliquer la page prcincipale de l'application
}

@Given("Je m'identfie en mode IBAN")
public void je_midentifie_en_mode_iban() {
    IBANPage IbanPage = idPage.clickBtnStartAccountTitle(); //Naviguer vers la page du compte IBAN
    IbanPage.clickIbanValidBtn(); //Valider le compte IBAN existant
    this.deliveryPage= IbanPage.clickConfirmBtn();
}

@When("Je peux remettre (.+) chèques")
public void je_peux_remettre_cheques(int n) {
    this.deliveryPage.clickDepositFakeBtn(n); //Déposer 5 chéques FAKE

}

@Then("Je peux valider le montant des chèques")
public void je_peux_valider_montant_cheques() throws InterruptedException {
    this.sumPage = this.deliveryPage.clickDepositStopBtn();//Naviguer vers la page devalidation de la somme d'un chèque
    this.sumPage.enterCheckSum("35,00"); //
}

@And("{string} message s'affiche")
public void message_saffiche(String string){
    String text = this.sumPage.getDisplayedText();
    Assert.assertEquals(text,string);
}

}

@CucumberOptions(features=“src/test/java/cucumber/iban.feature”
you have to put the path of your future file.

“<nombre de chèques>”

1 Like

Thank you! that solved some issues but I’m still getting the nullpointexception error on elements

can you show your code?

add code of this page. you have NULL there?