2016-02-22 36 views
0

错误我不能运行TestNG的测试,获得“Cannot find class in classpath: TestNG1”错误控制台。我不能运行TestNG的测试,得到“无法在类路径中寻找类:TestNG1”控制台

这是用TestNG

我不能运行TestNG的测试,我的第一次测试,让控制台“Cannot find class in classpath: TestNG1”的错误。

我不能运行TestNG的测试,获得“Cannot find class in classpath: TestNG1”错误控制台。

package automatiomFramework; 

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.support.ui.Select; 
import org.testng.annotations.Test; 
import org.testng.annotations.BeforeMethod; 
import org.testng.annotations.AfterMethod; 
import org.testng.TestNGException; 

public class TestNG1 { 

    public WebDriver driver; 

    @Test 
    public void f() { 

     driver.findElement(By.xpath(".//*[@id='topstrip123']/ul/li[5]/a")).click(); 

     Select oSelect = new Select(driver.findElement(By.id("ddlTitle"))); 
     oSelect.selectByIndex(2); 
     Select oSelect1 = new Select(driver.findElement(By.id("ddlTitle"))); 
     oSelect1.selectByVisibleText("Mr."); 

     driver.findElement(By.id("txtEmailsignup")).sendKeys("gjadj[email protected]"); 
     driver.findElement(By.id("txtPassword1")).sendKeys("password123"); 
     driver.findElement(By.id("txtCnfPassword")).sendKeys("password123"); 

     driver.findElement(By.id("Checkbox1")).click(); 
     driver.findElement(By.id("btnSignup")).click(); 
     driver.switchTo().alert().accept(); 
     driver.findElement(By.id("Checkbox1")).click(); 
     driver.findElement(By.id("btnSignup")).click(); 

     driver.switchTo().alert().accept(); 

     driver.findElement(By.id("chksubscribe")).click(); 
     WebElement radioBtn = driver.findElement(By.id("rbMailpre_1")); 

     radioBtn.click(); 

     driver.findElement(By.id("btnLogin")).click(); 
    } 

    @BeforeMethod 
    public void beforeMethod() { 
     driver = new FirefoxDriver(); 
     String url = "http://www.yepme.com"; 
     driver.get(url); 
    } 

    @AfterMethod 
    public void afterMethod() { 
     driver.close(); 
    } 

} 
+0

有你提到的testng.xml类的名字? –

+0

发布testng xml配置。 –

+0

我无法创建XML文件,它显示文件是空的。请帮助我。 – Sundarrajapandian

回答

0

创建一个名称的xml文件说的testng.xml下面的内容,并将其保存在Eclipse项目的根目录,然后右击testng.xml文件并选择Run As TestNG的套房。

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="XYZ" parallel="false"> 
    <test name="TESTING"> 
     <classes> 
      <class name="automatiomFramework.TestNG1" /> 
     </classes> 
    </test> 
</suite> 
相关问题