Search code examples
c#selenium-webdrivernunit

How can I get a RunTestParameter value from a .runsettings file?


  • I have a file called Test.runsettings which contains this:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>

    <!-- Parameters used by tests at run time -->
    <TestRunParameters>
        <Parameter name= "ScreenshotSaveLocation" value="" />
        <Parameter name= "HostUrl" value="http://10.18.0.110:654/"/>
        <Parameter name= "PipelineReleaseId" value=""/>
    </TestRunParameters>
    
</RunSettings>
  • Visual studio is looking for the correct .runsettings file
  • This is the code that is trying to access the parameter:
string domain = TestContext.Parameters["HostUrl"];

What am I doing wrong, please? It always returns null.


Solution

  • Turns out I hadn't pointed VS to the right location. It didn't throw an error when it couldn't find the file so I never knew!