0

我收到错误:java.lang.NoSuchMethodException:

这是我的代码

public class ManageEnrollmentTest {
    @Test
    public void Test_Filter_By_Active() throws Exception{

        assertTrue("Log in failed", Helper.LoginTest());

        assertTrue("Activation failed", fitlerResults("Active"));

    }

    private Boolean fitlerResults(String dS){
        Boolean isOk = false;
        try{
            JavascriptExecutor js = (JavascriptExecutor)driver;
            js.executeScript("$('#dType').val('36').change().trigger(\"liszt:updated\");;");

            WebElement findButton = driver.findElement(By.id("findDealersBtn"));
            findButton.click();

            Method method = ManageEnrollmentTest.class.getMethod("verifyActive");           //////// Error
            isOk = loadEnrollmentTablePageByPageAndVerify(method);
        }
        catch(Exception e){
            e.printStackTrace();
            isOk = false;
        }
        return isOk;
    }

    private Boolean loadEnrollmentTablePageByPageAndVerify(Method method){
        return (Boolean)method.invoke(this);
    }

    //browse throw all dealers that are currently on page
    private Boolean verifyActive(){
        ....
        ....
        return isOk;
    }
}
4

1 回答 1

3

您的方法是私有的,但getMethod()只返回公共方法。您需要使用getDeclaredMethod()

getMethod()-返回一个 Method 对象,该对象反映了此 Class 对象所表示的类或接口的指定公共成员方法。

于 2013-04-28T07:08:14.153 回答