2014-11-08 86 views
0

我寫了一個黃瓜功能導航到一個網站,搜索一些電話&驗證結果集中的電話價格。但是,聲明失敗,並顯示以下錯誤消息:cucumber-Junit斷言失敗 - 它無法斷言'£'sybmol

java.lang.AssertionError: Price is incorrect expected: < ?508.00> but was:<£508.00> 

您能幫我修復嗎?

我使用下列庫:

junit-4.11 
cucumber-core-1.1.5 
cucumber-html-0.2.3 
cucumber-java-1.1.5 
cucumber-junit-1.1.5 
cucumber-jvm-deps-1.0.3 
gherkin-2.12.1 
hamcrest-all-1.3 
selenium-server-standalone-2.43.1 

特性文件:

Feature: **** 
    phone search and price check feature 

Scenario: 

Given I am on ****** site 
When I search for an iPhone 
Then I should see the results showing phones at correct prices 
    | Results | Price | 
    | record1 | £508.00 | 
    | record2 | £415.00 | 
    | record3 | £364.99 | 
    | record4 | £418.00 | 
    | record5 | £421.00 | 

提取物從StepDefinition文件:

....... 

@Then("^I should see the results showing phones at correct prices$") 
public void validateTheResults(DataTable table) throws Throwable { 

    List<List<String>> data = table.raw(); 

    price = driver.findElement(By.xpath("//li[@id='result_0']/div/div/div/div[2]/div[2]/div[1]/div[1]/a/span")).getText(); 
    System.out.print("Price1 = " +price); 
    assertEquals("Price is incorrect",data.get(1).get(1),price); 
    ......... 

回答

1

這有可能是你得到一個字符設置不匹配。 Cucumber troubleshooting guide指出了幾個步驟。這裏有兩個可能是最相關的情況:

  1. 確保您.feature文件保存爲UTF-8
  2. 添加require 'cucumber/formatter/unicode'env.rb文件