Selenium - TestNG代碼不適用於我。第一個TestNG代碼不起作用
package firsttestngpackage;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.*;
定義TestNG的類
public class FirstTestNGFile {
public String baseURL = "http://newtours.demoaut.com/";
public WebDriver driver = new FirefoxDriver();
@Test
定義方法
public void verifyHomePageTitle() {
driver.get(baseURL);
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle = driver.getTitle();
Assert.assertEquals(actualTitle, expectedTitle);
driver.quit();
}
}
**我而用TestNG面臨以下錯誤**
org.testng.TestNGException:
Cannot instantiate class firsttestngpackage.FirstTestNGFile
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:31)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:410)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:323)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
可以添加完整的堆棧跟蹤? –
你可以分享整個FirstTestNGFile,或者至少是它的構造函數嗎? – juherr
嗨juherr,如果你在線,我可以與你分享我的屏幕? –