简体   繁体   中英

Retrieve count of method parameters and name of parameters in java

Retrieve count of method parameters and name of parameters in java.

public void verifyAboutUsPageUrlValidation(Integer inputNumber, Boolean expectedResult) throws Exception {
    //JavascriptExecutor js = (JavascriptExecutor) driver;
    //System.out.println((String)js.executeScript("arguments.length"));
    logger= report.startTest("verify AboutUs Page Url");
    logger.assignCategory("Rgression");

    logger.log(LogStatus.INFO, "Test start");

    System.out.println(inputNumber + " " + expectedResult);
    AboutUsPage about= new AboutUsPage(driver);
    about.CheckAboutUsPageUrlValidation(logger);    
    logger.log(LogStatus.INFO, "Test end");  
}

Reflection

To get the count of parameters of a method you can use reflection , specifically Method.getTypeParameters .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM