0

你好,我想在那里我能得到的报告和大量的测试失败或通过测试案例 下面的代码工作时,在正常的Java类跑到运行TestNG的类测试用例...运行测试用例TestNG的框架

@Test 
public void make() throws InterruptedException{ 
    System.setProperty("webdriver.chrome.driver","C:\\Users\\sasy\\Desktop\\Akhil\\Selenium\\chromedriver.exe"); 
    WebDriver driver=new ChromeDriver(); 
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 
    System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.Jdk14Logger"); 
    driver.get("http://198.57.218.124/CRFGLSPL/Private/login.aspx?ReturnUrl=%2fCRFGLSPL%2fPrivate%2fPatientOrganDamageIntermediateVisit.aspx%3fPatientID%3d2&PatientID=2"); 

    driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_txtEmail']")).sendKeys("[email protected]"); 
    driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_txtPassword']")).sendKeys("maryme"); 
    driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_btnLogin']")).click(); 
    driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_btnSubmit']")).click(); 
    driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_btnSubmit']")).click(); 
    //WebElement ID418=driver.findElement(By.xpath("//*[@id='edit41']")); 
    //WebElement ID830=driver.findElement(By.xpath("//*[@id='edit40']")); 
    WebElement ID969=driver.findElement(By.xpath("//*[@id='edit37']")); 
    //WebElement ID472=driver.findElement(By.xpath("//*[@id='edit39']")); 
    Thread.sleep(3000); 
    ID969.click(); 
    driver.quit(); 

} 

当上面的代码跑了作为TestNG的测试我正在给下面的错误

FAILED: make java.lang.NoClassDefFoundError: com/google/common/base/Function at first.heha.make(heha.java:16)

+0

你需要从的testng.xml运行>运行的TestNG的套件 – kushal

+0

http://stackoverflow.com/questions/5134953/noclassdeffounderror-in-java-com-google-common-base-function似乎相似到你的问题 – Grasshopper

+0

如果你的问题是根据你的喜好回答的,请考虑标记其中一个答案作为答案:[如何标记问题为答案](https://meta.stackexchange.com/questions/5234/how-does - 接受工作/ 5235#5235) – Thomas

回答

0

具有类com.google.common.base.Function,你最可能没有添加到类路径的jar文件。 添加番石榴jar文件到构建路径

检查,以确保所有必需的硒,TestNG的库在构建路径

+0

它没有为我工作,但谢谢 – Akhil

0

其实你的代码工作正常使用TestNG我已经试过了,所有你需要做的是将TeseNG Jars包含在你的类路径中,你可以通过下载TestNG jars并将其添加到你的类路径中来手工完成,或者如果你正在使用Maven,只需在你的pom.xml中添加TestNG依赖项

如果你使用maven运行你的测试

在你的pom.xml中添加下面的依赖关系

<dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>6.10</version> 
</dependency> 
+0

谢谢你做的伎俩 – Akhil

+0

不用客气 你可以请选择这个作为正确的答案 –

相关问题