2015-01-13 33 views
2

我編譯 我已經安裝了Specflow未能找到元素「specflow」的架構信息的Visual Studio專業2013

在Visual Studio我webdriver的C#代碼專業2013我碰到下面的錯誤 找不到架構信息爲元素「specflow」

我的AppConfig文件具有以下設置:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> 
    </configSections> 
    <specFlow> 
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc- config --> 
    </specFlow> 
    <appSettings> 
    ... 
    </appSettings> 
</configuration> 

爲什麼抱怨找不到specflow架構信息?

在我的步驟定義文件我已經包含在類

using NUnit.Framework; 
using OpenQA.Selenium; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using TechTalk.SpecFlow; 
using G.Selenium; 

namespace WebdriverBdd 
{ 
    [Binding] 
    public class SearchSteps : SeleniumWebDriver 
    { 
     [Given(@"user is on g search page")] 
     public void UserIsOnGSearchPage() 
     { 
      SeleniumWebDriver selenium_driver = new SeleniumWebDriver(); 
     } 
    } 
+0

您是否試過刪除然後重新添加Techtalk.SpecFlow Nuget包?您發佈的代碼和XML看起來不正確。 –

+0

我已刪除specflow Nuget包。全部保存。關閉並重新啓動Visual Studio。安裝Specflow Nuget。還是同樣的錯誤 –

+0

[這個問題](http://stackoverflow.com/questions/3173733/app-config-could-not-find-schema-information-after-converting-to-visual-studio)讓我思考。在「屬性」窗格可見的情況下,打開App.config,然後單擊編輯器中的源代碼。屬性窗格應該顯示一些信息給你。 Schemas屬性的價值是什麼?是否包含關於SpecFlow的任何內容? –

回答

1

注意的頂部:由於您的specFlow配置部分是空的,你可以將其刪除。在任何情況下,SpecFlow都將使用默認值。

無法找到元素'specFlow'的模式信息。

該消息(一個或多個)僅是信息。許多configSections沒有模式,因爲它們非常簡單,非常複雜或者有插件選項不能跟上。

您可以隨時從文檔或使用XML文件創建XML模式作爲示例。要從示例中創建一個(當然,這可能會過度適合該示例),請打開XML文件(app.config)並選擇菜單命令XML»Create Schema。

對於App.config,架構將用於整個配置。把它簡化到specflow配置部分。我用我的代碼生成了MS Test代碼,而不是NUnit。然後,我通過爲unitTestProvider的名稱創建一個枚舉來進行爵士化。

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="specFlow"> 
    <xs:annotation> 
     <xs:documentation> 
     Customizes SpecFlow code generation. This unofficial schema is hand-crafted based on actual use. 
     For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config. 

     Should occur zero or one times in an app.config. 
     </xs:documentation> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:choice minOccurs="0" maxOccurs="1"> 
      <xs:element name="unitTestProvider"> 
      <xs:complexType> 
       <xs:attribute name="name" type="SpecFlowUnitTestProvider" use="required" /> 
      </xs:complexType> 
      </xs:element> 
     </xs:choice> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
    <xs:simpleType name="SpecFlowUnitTestProvider"> 
    <xs:restriction base="xs:string"> 
     <xs:enumeration value="MsTest" /> 
     <xs:enumeration value="NUnit" /> 
    </xs:restriction> 
    </xs:simpleType> 
</xs:schema> 
相關問題