无法运行测试程序

问题描述 投票:0回答:1

我无法运行testng程序,因为它显示classpath错误。我已经添加了testng库:

org.testng.TestNGException:在类路径中找不到类:testngBasic

package mobileAutomation;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
    public class testngBasic {
    WebDriver driver;
    @BeforeMethod
    public void setUP() {
        System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://www.google.com");
    }
    @Test
    public void getTitle() {
        String googleTitle = driver.getTitle();
        System.out.println(googleTitle);
    }
    @AfterMethod
    public void closeBrowser() {
        driver.quit();  
    }
}
java selenium automation testng
1个回答
0
投票

只需执行Eclipse > Project > Clean,然后再次运行测试用例。应该可以。

© www.soinside.com 2019 - 2024. All rights reserved.