新设置eclipse和TestNG。我已经从selenium网站下载了Jar文件zip但是执行了例子FAILED CONFIGURATION:@BeforeMethod setUp java.lang.NoClassDefFoundError:即将到来
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.Assert;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Login {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@BeforeMethod
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://tssgmsw006:8080";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogin() throws Exception {
driver.get(baseUrl + "/GSSR/views/supplierSelectionAction.action");
driver.findElement(By.linkText("Advanced")).click();
driver.findElement(By.linkText("Basic")).click();
}
@AfterMethod public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Assert.fail(verificationErrorString);
}
}
}
输出: -
FAILED CONFIGURATION: @BeforeMethod setUp java.lang.NoClassDefFoundError: com/google/common/base/Function
答案 0 :(得分:0)
将此zip文件的srcs文件夹中的所有jar文件添加到eclipse中的构建路径。
http://selenium.googlecode.com/files/selenium-java-2.37.0.zip