java - 无法运行 testng 程序
问题描述
我无法运行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
,然后再次运行测试用例。它应该工作。
推荐阅读
- javascript - 从下载 URL 另存为 blob
- java - 编写用于从字符串中提取信息的正则表达式
- windows - 使用bat文件将路径变量写入ini
- javascript - 我已经开发了用 Anki 写中文。它在 Anki 中有效,但在 Ankidroid 中无效
- python - python for循环增量值不是同一个输入
- database - 开发概念证明数据仓库/市场(使用维度模型)
- excel - 使用 If 函数从另一个工作表中提取数据
- batch-file - 创建用于从 FTP 服务器下载 EXE 的批处理文件
- highcharts - Highcharts 列改变颜色,但标记/点不改变
- r - “iml”2D 累积局部效应 (ALE) 图