簡體   English   中英

Apache Ant:java.lang.ClassNotFoundException:

[英]Apache Ant: java.lang.ClassNotFoundException:

我正在嘗試使用Apache Ant運行以Java編寫的硒測試用例文件。 要設置此配置,我遵循了本教程。

以下是我在build.xml中的ant配置

<?xml version="1.0" encoding="UTF-8"?> 
   <project name="Hello World Project" default="info">
   <target name="info"> 
  <junit printsummary="yes" haltonfailure="yes">
    <classpath>  
      <pathelement path="lib\junit-4.10.jar" />
    </classpath> 
    <test name="com.lo.test.selenium.AssignCampaignTestCase"  haltonfailure="no" outfile="result"> 
      <formatter type="plain"/>
      <formatter type="xml"/> 
    </test> 
  </junit>
</target>
</project>

但是它顯示出如下錯誤:

          Testsuite: com.lo.test.selenium.AssignCampaignTestCase
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
        Caused an ERROR
    com.lo.test.selenium.AssignCampaignTestCase
    java.lang.ClassNotFoundException: com.lo.test.selenium.AssignCampaignTestCase
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:270)

AssignCampaignTestCase.java中的測試用例代碼

    package com.lo.test.selenium; 
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.Properties;
import java.util.ResourceBundle;

import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store; 
import javax.ws.rs.core.MediaType;

import org.junit.Test;
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.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.impl.MultiPartWriter;


/**
 * @author Ashutosh
 *
 */
 public class AssignCampaignTestCase {
     private static ResourceBundle rb = ResourceBundle.getBundle("global-messages");
    static WebDriver driver = new FirefoxDriver();  //Make it static in order to make one instance of this class(helps to avoid opening of 2 browsers at once)
    @Test
    public void campaignEmailTestCase() throws InterruptedException { 
        AssignCampaignTestCase emTesObj=new AssignCampaignTestCase();  
        // CommonMethods commonMethods=new CommonMethods();
        String fName="test LO";
        Integer LeadId=570903;
        String campaignName="2GetMoreLeads"; 
        String SubjName="Welcome to your 5-day challenge and tips";   //NOTE: No problem,Type without double quotes. It will work for you 
        doLogin(driver); 
        emTesObj.goToLeadsListPage();
        emTesObj.searchByFirstName(fName);//without this also,it will work but Gives you the correct navigation on UI
        emTesObj.waitBeforePageLoads(LeadId.toString()); //pass the Id attribute which you aspect to see after the page is loaded
        emTesObj.assignCampaign(LeadId, campaignName);  
        emTesObj.readRecentEmail(SubjName);  
    }


     //shows you the leads List Page     
     public void goToLeadsListPage(){ 
         driver.get("http://www.xxxxx.com/orderManagement/xxxx.action");
     }
       .................
       .................
       .................

這是我的項目結構::::

在此處輸入圖片說明

請幫助我使用Ant運行我的項目。

嘗試在您的類路徑中添加硒jar文件。 當前,您僅添加了junit。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM