Selenium 我无法运行TestNG测试,因为我得到;在类路径中找不到类:TestNG1;控制台中的错误

Selenium 我无法运行TestNG测试,因为我得到;在类路径中找不到类:TestNG1;控制台中的错误,selenium,Selenium,我无法运行TestNG测试,控制台中出现“无法在类路径中找到类: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.s

我无法运行TestNG测试,控制台中出现“
无法在类路径中找到类: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("gjadjdsga@gmail.com");
        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();
  }

}
这是我第一次使用TestNG进行测试

我无法运行TestNG测试,控制台中出现“
无法在类路径中找到类: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("gjadjdsga@gmail.com");
        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();
  }

}
我无法运行TestNG测试,控制台中出现“
无法在类路径中找到类: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("gjadjdsga@gmail.com");
        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();
  }

}

创建一个名为testNG.xml的xml文件,其中包含以下内容,并将其保存在eclipse中项目的根目录中,然后右键单击testNG.xml并选择RunasTestNG套件

<?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>


您提到testng.xml中的类名了吗?发布testng xml配置。我无法创建xml文件,它显示文档为空。请帮我做这个。