0

运行 Testng 程序时出现此错误:

java.lang.ExceptionInInitializerError
    at com.org.dnb.po.test.loginpagePOTest.verifyLoginpagecontrols(loginpagePOTest.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

我有两个类,一个用于定义(class-1),另一个是测试(class-2)

第一类:

public static List<WebElement> unameBox1= driver.findElements(By.xpath(".//*[@id='username']"));
public static boolean unameboxIT = unameBox1.size() > 0;

类2:

@Test(priority=1)
public void verifyLoginpagecontrols(){

    Assert.assertTrue(unameboxIT); // Always goes into Exception as shown above
}

好心的帮助

4

0 回答 0