• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • All
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • 3D printing
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Chatbots
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DataOps
    • Developers life
    • DevOps
    • Digital Days
    • Digital Twin
    • Docker
    • eHealth
    • Enterprise Architecture
    • Event Sourcing
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • All
    • Bloggers
    • Speakers
Home » Data driven UI Tests, fixing the data connection when executing on a remote agent
  • Data driven UI Tests, fixing the data connection when executing on a remote agent

    • By Marcel de Vries
    • Various 9 years ago
    • Various 0 comments
    • Various Various
    Data driven UI Tests, fixing the data connection when executing on a remote agent

    *Moved to: http://fluentbytes.com/data-driven-ui-tests-fixing-the-data-connection-when-executing-on-a-remote-agent/

    This week I deployed a CodedUI solution with a customer where we created an extensive UI automation framework based on the page object pattern I described in one of my previous post.

    One additional thing we added was the option to separate the test data entered in the UI from the actual tests. For this I leveraged the DataSource attribute that you can apply to any MS test based test, to bind to an Excel data sheet. In this sheet we created a sheet per logical data entity, so we could maintain the data scenarios separate from the C# code.

    Here is an example of how to do this:

    [TestMethod]
    [DataSource("TestScenariosParticulier")]
    public void TestScenario1()
    {
        const string scenario = "Scenario1";
        // Load data from Excel
        var testcase = new ExcelDataTestcase(TestContext, scenario);
        
        // Create a new page object
        var polisManager = new PolisAanmaken(driver, testcase);
        
        string PolicyNummer= polisManager.GetTravelPolicy().PolicyNummer;
        
        Assert.IsTrue(int.TryParse(PolicyNummer),"Expect ploicy number is an Integer");
    }
    

    I won’t go into the details of loading the excel data sheet here, but the point is that the data source attribute points to a configfile that contains a pointer to the data source. The config file looks as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </configSections>
        <connectionStrings>
            <add name="TestScenariosParticulierXlsxConnection" connectionString="Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xlsx)};dbq=|DataDirectory|TestScenarios_particulier.xlsx;defaultdir=.;driverid=790;maxbuffersize=2048; pagetimeout=5;readonly=true;Extended Properties='HDR=NO'" providerName="System.Data.Odbc" />
        </connectionStrings>
        <microsoft.visualstudio.testtools>
            <dataSources>
                <add name="TestScenariosParticulier" connectionString="TestScenariosParticulierXlsxConnection" dataTableName="Driver$" dataAccessMethod="Sequential"/>
            </dataSources>
        </microsoft.visualstudio.testtools>
    </configuration>
    

    In this config file you can see I use an excel sheet called TestScenarios_Particulier.xlsx.

    Now this all worked great on the developer machine, but when I wanted to run the automated test using Microsoft Test Manager (MTM) it just did not work. In MTM you can configure a test case to be automated and then the test is executed using the provided Build definition (to find the actual automation code) and the configured the Test Controller and Test Agent. For this purpose we create a new fresh test machine that contains nothing more then the browsers we wanted to use for the tests (IE, Firefox and Chrome) and the Cross browser components for CodedUI.

    When I executed the tests, I constantly received the following error:

    error

    The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see “Troubleshooting Data-Driven Unit Tests” (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.Error details: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    Unfortunately the link provided in the error does not help much, since it points to a generic article on testing.

    So after some digging around I found that the solution to this problem was to install the “2007 Office System Driver: Data Connectivity Components“

    We used a new fresh machine containing Windows Server 2012 as the operating system. But apparently when you look at the ODBC configuration on this machine, default there are no drivers available for Excel. I first tried to fix this by installing Excel itself on the machine, but that did not solve the issue either. To be honest I am glad for that, since I did not like the fact that I would need to install Excel on the machine to use the sheets. Luckily the driver package for Office 2007 solves the issue that the ODBC driver for Excel could not be found.

    So installing the driver package solved the error and now my tests work great, straight from MTM. I now can click RunWithOptions and then select my test machine to run the test. After a few seconds, you can then watch the browser start and the test go through the scenario and all is nicely reported back to MTM, including a video recoding of the test run. Now that is Nice!

    So I hope my Endeavour in fixing the issue will help you out as well, when you try to build data driven CodedUI tests.

    Enjoy!

    Marcel

    Follow my new blog on http://fluentbytes.com

    Share this

Marcel de Vries

View profile

IT Training at Info Support

Which training fits you?

Consultancy

Consultancy

Related blogs

  • Video Conferencing en OBS Studio koppelen: online prese…

    Video Conferencing en OBS Studio koppelen: online prese… Maaike Brouwer - 2 years ago

  • Verantwoordelijkheid pakken in jouw eigen persoonlijke …

    Verantwoordelijkheid pakken in jouw eigen persoonlijke … Stephan Versteegh - 2 years ago

  • Tips voor als je gaat afstuderen

    Tips voor als je gaat afstuderen Bart Renders - 2 years ago

Data Discovery Channel

  • Explainable AI - Break open the blackbox

  • Toekomstvaste microservice data architecturen

  • Modern Data Platform

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel Always active
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Manage options Manage services Manage vendors Read more about these purposes
Voorkeuren
{title} {title} {title}