Java Atlassian竹子日志:[testng]在类路径com.vaannila.domain.UserTest中找不到类

Java Atlassian竹子日志:[testng]在类路径com.vaannila.domain.UserTest中找不到类,java,ant,testng,selenium-chromedriver,bamboo,Java,Ant,Testng,Selenium Chromedriver,Bamboo,我面临的错误是testNG无法在类路径中找到类。但是我很确定我提到了正确的类路径 这是我的testng.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="User Registration suite 1" verbose="1" > <test name="Regres

我面临的错误是testNG无法在类路径中找到类。但是我很确定我提到了正确的类路径

这是我的testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="User Registration suite 1" verbose="1" >
  <test name="Regression suite 1" >
    <classes>
      <class name="com.vaannila.domain.UserTest"/>
    </classes>
 </test>
</suite>

这是我的UserTest.java类:

package com.vaannila.domain;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
//Java imports
import java.util.concurrent.TimeUnit;
import java.util.List;

public class UserTest {
    private WebDriver driver;
    private String baseUrl;

 @BeforeTest
 public void beforeTest() throws Exception {
     //giving the location where selenium chrome driver is located in my file system
     System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
     //if chrome driver has to work on a CI server, then we have to additionally install xvfb and reboot the server. So, we are going to circumvent all that and leverage chrome sans GUI via headless mode.
     ChromeOptions co = new ChromeOptions();
     //Now we have to add headless arguments to our chrome driver
     co.addArguments("--headless");
     co.addArguments("--start-maximized");
     //initializing a chrome driver with driver object
     driver = new ChromeDriver(co);
     //asking the chrome driver to implicitly wait for 5 seconds before moving on
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
     //setting the value of baseUrl variable
     baseUrl = "http://xx.xx.xx.xx:9999/myuser/userRegistration.htm";
     }  

 @Test
  public void userreg() throws InterruptedException{
    //this step opens up chrome browser with the aforementioned application
            driver.get(baseUrl);

            //getting web elements of name and password. Then we send info to those via sendKeys()
            System.out.println("Getting ready to register a user by getting details from them");
            WebElement name = driver.findElement(By.id("name"));
            WebElement password = driver.findElement(By.id("password"));
            name.sendKeys("aditya");
            password.sendKeys("aditya123");
            System.out.println("fields set...");

            //getting radio element buttons in our user registration webpage
            WebElement radio1 = driver.findElement(By.id("gender1"));
            WebElement radio2 = driver.findElement(By.id("gender2"));
            WebElement radio3 = driver.findElement(By.id("gender3"));

            //toggling radio buttons
            radio1.click();
            System.out.println("Radio 1 button is selected");

            radio2.click();
            System.out.println("Radio 2 button is selected");

            radio3.click();
            System.out.println("Radio 3 button is selected");

            //Selecting country from Drop down ( Used Id to identify the element )
            Select options = new Select(driver.findElement(By.id("country")));
            //selecting India option via select by visible text
            options.selectByVisibleText("India");
            //Using sleep command so that the change is visible
            Thread.sleep(2000);

            //selecting USA via select by index mechanism
            options.selectByIndex(2);
            //using sleep command so that the change is visible
            Thread.sleep(2000);

            //Print all the options for the selected drop down and select one option of your choice
            // Get the size of the Select element
            List<WebElement> optionsize = options.getOptions();
            int iListSize = optionsize.size();

            //using for loop to go through all options in drop down
            for(int i=0;i<iListSize;i++) {
                //storing the value of an option sValue variable
                String sValue = options.getOptions().get(i).getText();
                //printing out the variable
                System.out.println(sValue);
                // Putting a check on each option that if any of the option is equal to 'USA' then select it
                if(sValue.equals("India")) {
                    options.selectByIndex(i);
                    break;
                }
            }

            //Getting the textarea element of our webpage
            WebElement textbox = driver.findElement(By.id("aboutYou"));
            textbox.sendKeys("I am a good boy who is looking to learn java");

            //getting checkbox elements of our webpage and toggling them
            WebElement option1c = driver.findElement(By.id("community1"));
            option1c.click();

            if(option1c.isSelected()) {
                System.out.println("Checkbox is toggled on");
            } else {
                System.out.println("Checkbox is toggled off");
            }

            //selecting another element (mailing list option) in our webpage
            WebElement mail = driver.findElement(By.id("mailingList1"));
            mail.click();

            if(mail.isSelected()) {
                System.out.println("Checkbox is toggled on");
            } else {
                System.out.println("Checkbox is toggled off");
            }

            //getting the submit option of our webpage
            WebElement query = driver.findElement(By.cssSelector("input"));
            query.click();
            System.out.println("done submitting...");

            //clearing all the fields of our webpage
            name.clear();
            password.clear();
            textbox.clear();
            System.out.println("Fields cleared...");
  }

  @AfterTest
  public void afterTest() throws Exception {
      driver.close();
  }

}
<?xml version="1.0" ?>
<project name="UserRegistrationAnt" default="war" basedir="." xmlns:sonar="antlib:org.sonar.ant">

    <!-- Beginning of project dir definition -->
    <property name="testng.xml.file" value="testng.xml" />
    <property name="basedir" location="." />
    <property name="src" location="${basedir}/src" />
    <property name="lib" location="${basedir}/WebContent/WEB-INF/lib" />
    <property name="build" location="${basedir}/target/classes" />
    <property name="war-file" location="${basedir}/dist" />
    <property name="test-reports" location="{basedir}/test-reports" />
    <!-- End of project dir definition -->
    <!-- Beginning of sonar properties definition -->
    <property name="sonar.host.url" value="http://xx.xx.x.xxx:9000" />
    <property name="sonar.projectKey" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectName" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectVersion" value="1.0" />
    <property name="sonar.language" value="java" />
    <property name="sonar.sources" value="${src}" />
    <property name="sonar.java.binaries" value="${build}" />
    <property name="sonar.sourceEncoding" value="UTF-8" />
    <!-- End of sonar properties definition -->


    <!-- Definition of external dependencies location -->
    <path id="compile.classpath">
        <fileset dir="${lib}">
                        <include name="*.jar"/>
                </fileset>
        </path>

    <!-- Making dirs for compiled, war file and test reports-->
        <target name="init">
        <mkdir dir="${build}"/>
        <mkdir dir="${war-file}" />
        <mkdir dir="${test-reports}" />
    </target>

    <!-- Compilation of our source and test code -->
        <target name="compile" depends="init" >
        <javac destdir="${build}" debug="true" srcdir="${src}" classpathref="compile.classpath" includeantruntime="false" />
        </target>

    <!-- Execution of testng -->
    <taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="compile.classpath" />
    <target name="tests" depends="compile">
        <testng outputdir="${test-reports}" classpathref="compile.classpath" haltOnFailure="true">
            <classpath location="{build}" />
            <xmlfileset dir="${basedir}" includes="${testng.xml.file}" />
        </testng>
    </target>

    <!-- Execution of sonar analysis -->
    <target name="sonar" depends="compile">
        <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
            <!-- update the following line or put sonar-ant-task-*.jar in $ANT_HOME/.ant/lib folder -->
            <classpath path="/opt/ant/apache-ant-1.10.5/lib/sonarqube-ant-task-2.5.jar" />
        </taskdef>
        <!-- Execute SonarQube scanner for ant analysis -->
        <sonar:sonar />
    </target>

        <target name="war" depends="compile">
        <war destfile="{war-file}/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
            <fileset dir="${basedir}/WebContent"/>
            <lib dir="${lib}"/>
            <classes dir="${build}"/>
                </war>
        </target>

        <!--target name="clean">
                <delete dir="dist" />
                <delete dir="build" />
                <delete dir="reports" />
    </target-->

    <target name="all" depends="init, compile, tests, sonar, war" description="one single target to fire up every ant build stage" />

</project>
package com.vaannila.domain;
导入org.testng.annotations.Test;
导入org.testng.annotations.BeforeTest;
导入org.testng.annotations.postest;
导入org.openqa.selenium.chrome.ChromeDriver;
导入org.openqa.selenium.chrome.ChromeOptions;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.By;
导入org.openqa.selenium.support.ui.Select;
//Java导入
导入java.util.concurrent.TimeUnit;
导入java.util.List;
公共类用户测试{
私有网络驱动程序;
私有字符串baseUrl;
@试验前
public void beforeTest()引发异常{
//给出selenium chrome驱动程序在我的文件系统中的位置
System.setProperty(“webdriver.chrome.driver”,“/usr/local/bin/chromedriver”);
//如果chrome驱动程序必须在CI服务器上工作,那么我们必须另外安装xvfb并重新启动服务器。因此,我们将绕过所有这些,通过无头模式利用chrome SAN GUI。
ChromeOptions co=新的ChromeOptions();
//现在我们必须在chrome驱动程序中添加无头参数
公司名称(“无头”);
co.addArguments(“--start maximized”);
//使用驱动程序对象初始化chrome驱动程序
驱动器=新的镀铬驱动器(co);
//要求chrome驱动程序在继续之前隐式等待5秒钟
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
//设置baseUrl变量的值
baseUrl=”http://xx.xx.xx.xx:9999/myuser/userRegistration.htm";
}  
@试验
public void userreg()引发InterruptedException{
//此步骤将使用上述应用程序打开chrome浏览器
get(baseUrl);
//获取名称和密码的web元素。然后我们通过sendKeys()向这些元素发送信息
System.out.println(“通过获取用户的详细信息来准备注册用户”);
WebElement name=driver.findElement(By.id(“name”));
WebElement password=driver.findElement(By.id(“密码”);
名称。发送键(“aditya”);
密码。发送密钥(“aditya123”);
System.out.println(“字段集…”);
//在我们的用户注册网页中获取单选元素按钮
WebElement radio1=driver.findElement(By.id(“gender1”);
WebElement radio2=driver.findElement(By.id(“gender2”);
WebElement radio3=driver.findElement(By.id(“gender3”);
//切换单选按钮
radio1.单击();
System.out.println(“选择单选1按钮”);
radio2.单击();
System.out.println(“选择单选2按钮”);
radio3.单击();
System.out.println(“选择单选3按钮”);
//从下拉列表中选择国家(用于标识元素的Id)
选择选项=新选择(driver.findElement(By.id(“国家”));
//通过“按可见文本选择”选择“印度”选项
选项。选择VisibleText(“印度”);
//使用sleep命令使更改可见
《睡眠》(2000年);
//通过索引选择机制选择美国
选项。选择索引(2);
//使用sleep命令使更改可见
《睡眠》(2000年);
//打印所选下拉列表的所有选项,然后选择一个选项
//获取Select元素的大小
列表选项size=options.getOptions();
int-iListSize=optionsize.size();
//使用for循环遍历下拉列表中的所有选项
对于(int i=0;i
我对这个错误一无所知。我已经提到了,但是我的构建在eclipse IDE和cmd.exe中没有出现故障,但是在Atlassian Bambol CI服务器中出现了上述错误。因此,这个问题和我的问题完全不同。我无法在CI服务器中清理和构建


我需要有关解决此错误的帮助。

哎呀……我错过了
测试
目标下
{build}
附近的
$

抱歉给你添麻烦了

一个指向所有人的指针:小心使用类名和变量 一个简单而愚蠢的错误可以带来进步 而这类错误是很难发现的

问候


再见

请接受你自己的答案,这样问题就结束了。