我得到错误: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;
}
}
你的方法是私有的,但是getMethod()只返回公共方法。你需要使用getDeclaredMethod()。
getMethod()
- 返回一个Method对象,该对象反映由这个class对象表示的类或接口的指定的public成员方法。