Ant执行脚本在控制台输出中文乱码

上一篇 / 下一篇  2013-02-27 14:59:16 / 个人分类:TestNG/Ant/Eclipse/Java

没整出来原因....改天再试
build.xml: 已经改成UTF-8了,还是不行
<!--compile-->
 <target name="compile" depends="init">
 <mkdir dir="${classes}" />
 <javac destdir="${classes}" includeantruntime="false" debug="on" encoding="UTF-8">
 <!-- <compilerarg line="-encoding UTF-8"/> -->
<classpath refid="classpath" />
 <src path="${src}" />
 <include name="*.java" />
 <include name="**/*.java" />
 </javac>
 <copy todir="${classes}">
 <fileset dir="${src}">
 <exclude name="**/*.java" />
 </fileset>
 </copy>
 </target>
 
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite">
<!--<parameter name="baseUrl" value="https://axo.citsamex.com/onlineHEAD"/> -->
 <test verbose="2" name="Default test" >
  <classes>          
   <class name="test.NewTest1"/>
    <methods>      
    <include name="f"/> 
    </methods>              
  </classes>
 </test> <!-- Default test -->
</suite> <!-- Default suite -->
 
 
src:
package test;
import java.io.UnsupportedEncodingException;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
import com.citsamex.axo.domair.CommonFunction;
public class NewTest1 extends CommonFunction
{
  @Test
  public void f()
  {
  onlineLogin(companyId,userName,passWord);
  
  driver.findElement(By.cssSelector("a.clsA")).click();//click domair tab
  driver.findElement(By.xpath("//input[@name='domesticFlightSearchVO.domAirType']")).click();//one way
  waitForTime(1000); 
   //Departure city
   driver.findElement(By.id("oneWayDeparture")).click();
   driver.findElement(By.id("oneWayDeparture")).clear();
   driver.findElement(By.id("oneWayDeparture")).click();
   waitForTime(1000); 
   driver.findElement(By.id("oneWayDeparture")).sendKeys("天津");
   waitForTime(1000); 
   pressEnterKey(); 
   //Arrive city
   driver.findElement(By.id("oneWayArrive")).click();
   driver.findElement(By.id("oneWayArrive")).clear();
   driver.findElement(By.id("oneWayArrive")).click();
   waitForTime(1000);
   driver.findElement(By.id("oneWayArrive")).sendKeys("北京");
   waitForTime(1000);
   pressEnterKey();
  //Departure Date
  driver.findElement(By.id("oneWayDepartureDate")).click();
  driver.findElement(By.id("oneWayDepartureDate")).clear();
  driver.findElement(By.id("oneWayDepartureDate")).click();
  waitForTime(1000);
  if(oneWayDepartureDate!=null)
   driver.findElement(By.id("oneWayDepartureDate")).sendKeys(oneWayDepartureDate);
  else   
   driver.findElement(By.id("oneWayDepartureDate")).sendKeys(nextMonthToday());     
  waitForTime(1000); 
  pressEnterKey();
  //read time
  new Select(driver.findElement(By.id("oneWayDepartureTime"))).selectByVisibleText("00:00-24:00");
  //select cabin code
  new Select(driver.findElement(By.id("cabinCode"))).selectByValue(cabinCodeFCY);
  waitForTime(1000); 
  //click search button
  driver.findElement(By.id("searchFlightBtn")).click();
  waitForTime(5000);
  if(!driver.getCurrentUrl().startsWith(searchDomesticFlightActionUrl))
   System.out.println("domestic flight one way search failed, pls check...");
   if(driver.findElement(By.cssSelector("div.wrong>div.wrong-x>p.Prompt")).isDisplayed())
    {     
     System.out.println("乱码+luanma+乱码" );       
        System.out.println("the departure city is: "+driver.findElement(By.id("oneWayDeparture")).getAttribute("value"));
     System.out.println("the arrive city is: "+driver.findElement(By.id("oneWayArrive")).getAttribute("value"));
    } 
}
}
expect result console:
乱码+luanma+乱码
the departure city is: 天津
the arrive city is: 北京
PASSED: f

TAG:

 

评分:0

我来说两句

日历

« 2024-05-12  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 74630
  • 日志数: 80
  • 建立时间: 2012-04-12
  • 更新时间: 2013-05-21

RSS订阅

Open Toolbar