I am trying to pass the Browser Type for 45 projects from a single place using Parallel.RunSettings
file and adding this file under Test Settings in Visual Studio.
But the value is not being read with NullReferenceException
.
Am I missing any step?
Currently we are passing browser type for each project in their respective app.config
file but I want to do it from one single place.
Here is my code:
Parallel.runsettings
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>4</MaxCpuCount>
</RunConfiguration>
<TestRunParameters>
<Parameter name="browsertype" value="Firefox" />
</TestRunParameters>
</RunSettings>
Code to Fetch the value:
public string GetBrowser
{
get
{
var value =Convert.ToString(testContext.Properties["browsertype"]);
return value;
}
}
//Code To Launch the browser:
if (config.GetBrowser == "Firefox")
{
this.WebDriver = new FirefoxDriver();
}
else if (config.GetBrowser == "Chrome")
{
var chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
this.WebDriver = new ChromeDriver(chromeOptions);
}
else if (config.GetBrowser == "IE")
{
this.WebDriver = new InternetExplorerDriver();
}