Selenium 参数应用的非法修改器;只允许决赛

Selenium 参数应用的非法修改器;只允许决赛,selenium,selenium-webdriver,testng,Selenium,Selenium Webdriver,Testng,我创建了一个名为BaseClass的类,该类将在InvalidLogin类中进行扩展。在基类中,有一个方法显示以下错误消息: 这条线上有多个标记 -语法错误,请插入“;”以完成LocalVariableDeclarationStatement -语法错误,请插入“[]”以完成维度 -令牌“closeApplication”上出现语法错误,后面应为AnnotationName 这个令牌 -void[]是无效的类型 -参数关闭应用的非法修饰符;只允许期末考试 下面是上面引用的两个类以及Eclipse

我创建了一个名为BaseClass的类,该类将在InvalidLogin类中进行扩展。在基类中,有一个方法显示以下错误消息:

这条线上有多个标记 -语法错误,请插入“;”以完成LocalVariableDeclarationStatement -语法错误,请插入“[]”以完成维度 -令牌“closeApplication”上出现语法错误,后面应为AnnotationName 这个令牌 -void[]是无效的类型 -参数关闭应用的非法修饰符;只允许期末考试

下面是上面引用的两个类以及Eclipse提供的错误图像

    public class BaseClass {

    WebDriver driver;
    @BeforeClass
    public void setupApplication() {
        Reporter.log("Instanciando o navegador", true);
        driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get("http://enterprise.demo.orangehrmlive.com/symfony/web/index.php/auth/login");
        Reporter.log("Aplicação inicializada", true);

        @AfterClass
        public  void closeApplication() {
            driver.quit();
            Reporter.log("Sessão do navegador finalizada");
        }       
    }
}


    public class InvalidLogin extends BaseClass {

    @Test(description = "This Test Case will perform valid login")
    public void loginApplicationValid() {
        try {
            driver.findElement(By.name("txtUsername")).sendKeys("Admin1");
            driver.findElement(By.id("txtPassword")).sendKeys("admin1");
            driver.findElement(By.id("btnLogin")).click();
            driver.navigate().back();
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    @Test(description = "This Test Case will perform invalid login")
    public void loginApplicationInvalid() {
        driver.findElement(By.name("txtUsername")).sendKeys("admin1");
        driver.findElement(By.id("txtPassword")).sendKeys("admin2");
        driver.findElement(By.id("btnLogin")).click();
    }
}


您没有正确关闭方法设置应用程序。只需在方法closeApplication之前添加结束括号,如下所示

public class BaseClass {

WebDriver driver;
@BeforeClass
public void setupApplication() {
    Reporter.log("Instanciando o navegador", true);
    driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://enterprise.demo.orangehrmlive.com/symfony/web/index.php/auth/login");
    Reporter.log("Aplicação inicializada", true);
    }

    @AfterClass
    public  void closeApplication() {
        driver.quit();
        Reporter.log("Sessão do navegador finalizada");
    }       
}