Wednesday, February 5, 2025

Java maven – IllegalArgumentException: Enter have to be set


I bought virtually equivalent console output as what you shared above. A sure take a look at of mine wouldn’t even run step one, which instructed me it had one thing to do with my ‘DriverUtils’ or my ‘Hooks’.

The start of my characteristic file:


@ProdSmoke @TC1.38 @ARCCP-T138 @TestCaseKey=ARCCP-T138
State of affairs: Consumer logs in, clicks important buttons, logs out, logs in, logs out

    # navigate to PROD CLIENT PORTAL
Given consumer navigates to "https://our-website-url.com/login"
And consumer has entered legitimate prod username and legitimate password 

My Hooks file regarded like this:


import api.providers.AuthenticationControllerService;
import context.SharedContext;
import io.cucumber.java.After;
import io.cucumber.java.Earlier than;
import io.cucumber.java.State of affairs;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import utils.CommonMethods;
import utils.ConfigReader;
import utils.DriverUtils;

public class Hooks {
    personal static String authorizationToken = "";
    AuthenticationControllerService authenticationControllerService = new AuthenticationControllerService();
    @Earlier than("@UI")
    public void setUp() {
        ConfigReader.initializeProperties();
        DriverUtils.createDriver();
    }
    @Earlier than("@API")
    public void setupBaseURIGetToken(){
        ConfigReader.initializeProperties();
        RestAssured.baseURI = ConfigReader.getProperty("authorization.url");

        Response authResponse = authenticationControllerService.authorizeAdmin(RestAssured.baseURI);
        String responseBody = authResponse.getBody().asString();

        authorizationToken = authResponse.jsonPath().getString("token");
        System.out.println("Authorization token: " + authorizationToken);

        SharedContext sharedContext = SharedContext.getInstance();
        sharedContext.setAPIAuthToken(authorizationToken);
        sharedContext.setResponseBody(responseBody);
    }
    public String getAuthToken(){
        return authorizationToken;
    }

    @After("@UI")
    public void cleanUp(State of affairs situation) throws InterruptedException {
        if (situation.isFailed()) {
            situation.connect(CommonMethods.takeScreenshot(), "picture/png", situation.getName());
        }
        CommonMethods.takeScreenshot(situation);
        Thread.sleep(3000);
        DriverUtils.getDriver().give up();
    }
} 

Observe that my ‘public void setUp()’ technique in Hooks exhibits the tag @UI within the @Earlier than as ‘@Earlier than(“@UI”)’ above it. I one way or the other had eliminated the ‘@UI’ tag from above the ‘State of affairs’ line in my Function File. So, I wasn’t calling the ‘setUp’ technique within the very first place. Including that fastened all the pieces, so the start of my Function File appears to be like like this:

Function: ARCCP-T001 - Sanity Take a look at of PROD COMPANY Shopper Portal Important Performance

@ProdSmoke @TC1.38 @ARCCP-T138 @TestCaseKey=ARCCP-T138 @UI
State of affairs: Consumer logs in, clicks important buttons, logs out, logs in, logs out

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com