我无法运行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
,然后再次运行测试用例。应该可以。