2

I am compiling my webdriver C# code in Visual Studio professional 2013 I have installed Specflow

I get the following error could not find schema information for the element 'specflow'

My AppConfig file has the following settings:

<?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>

Why is it complaining about could not find schema info for specflow?

In my step definition file i have included at the top of the class

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();
        }
    }
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
Riaz Ladhani
  • 3,946
  • 15
  • 70
  • 127
  • Have you tried removing and then re-adding the Techtalk.SpecFlow Nuget package? The code and XML you've posted doesn't look incorrect. – Greg Burghardt Jan 13 '15 at 19:00
  • I have removed specflow Nuget package. Saved All. Closed and restarted Visual Studio. Installed Specflow Nuget. Still same error – Riaz Ladhani Jan 13 '15 at 20:42
  • [This SO question](http://stackoverflow.com/questions/3173733/app-config-could-not-find-schema-information-after-converting-to-visual-studio) got me thinking. With the Properties pane visible, open App.config and then click on the source code within the editor. The Properties pane should show some info for you. What is the value of the `Schemas` property? Is anything regarding SpecFlow included? – Greg Burghardt Jan 13 '15 at 21:06
  • The value of Schemas is "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\DotNetConfig45.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\EntityFrameworkConfig_6_0_0.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\RazorCustomSchema.xsd" – Riaz Ladhani Jan 13 '15 at 21:13
  • Ok. Hm. Looks similar to what I've got. Did you install the SpecFlow extension for Visual Studio? – Greg Burghardt Jan 13 '15 at 21:16
  • Specflow I have installed, just installed Splcflow.Nunit – Riaz Ladhani Jan 13 '15 at 21:35
  • To run and compile a project that uses SpecFlow, you need both the SpecFlow extension for Visual Studio _and_ the SpecFlow package for Nuget. Do you have both? It's hard to tell from your last comment. If you have both, it might be worth uninstalling the SpecFlow extension for Visual Studio and reinstalling it. – Greg Burghardt Jan 13 '15 at 21:48
  • I think I have the Specflow package. in manage NuGet Packages it shows Specflow ticked and SpecFlow.Nunit ticked. How do i know which is the specflow extension? – Riaz Ladhani Jan 16 '15 at 20:36
  • Should I install the Specflow.CustomPlugin? – Riaz Ladhani Jan 16 '15 at 20:36
  • 1
    That's under Tools > Extension Manager. You need to install the SpecFlow extension for Visual Studio and the SpecFlow NuGet package to get things to work. – Greg Burghardt Jan 16 '15 at 21:54

1 Answers1

2

Note: Since your specFlow config section is empty, you can just delete it. SpecFlow will use defaults for everything in either case.

Could not find schema information for the element 'specFlow'.

The message(s) are informational only. Many configSections don't have schemas because they are very simple, very complex or have plugin options that aren't kept up with.

You can always create an XML schema from documentation or using an XML file as an example. To create one from an example (which of course, might be overfit to the example), open the XML file (app.config) and select the menu command XML » Create Schema.

In the case of an App.config, the schema will be for the whole configuration. Simply pare it down to the specflow config section. I did this with mine, which directs code generation for MS Test instead of NUnit. I then jazzed it up a bit by creating an enumeration for the name of the 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>
Tom Blodget
  • 20,260
  • 3
  • 39
  • 72