我无法运行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();
    }
}

最佳答案

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

关于java - 无法运行testng程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59693027/

10-14 04:45