Tech Stack: C#, SpecFlow, WinAppDriver, Nunit [Test Runner]

Scenario:

This is an Automation Test project where I need to integrate parallel testing using Selenium grid architecture. I have setup HUB and NODE and when I try to run multiple test cases [Say 2] I get the below exception.


BoDi.ObjectContainerException: Multiple public constructors with the same maximum parameter count are not supported

Stack Trace:

----> BoDi.ObjectContainerException : Multiple public constructors with same maximum parameter count are not supported! OpenQA.Selenium.Appium.AppiumDriver`1[[OpenQA.Selenium.Appium.Windows.WindowsElement, Appium.Net, Version=4.2.0.0, Culture=neutral, PublicKeyToken=null]] Stack Trace: RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ObjectContainer.CreateObject(Type type, ResolutionList resolutionPath, RegistrationKey keyToResolve) TypeRegistration.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath) ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath) ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name) ObjectContainer.Resolve(Type typeToResolve, String name) TestObjectResolver.ResolveBindingInstance(Type bindingType, IObjectContainer container) line 11 lambda_method(Closure , IContextManager , String ) BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) line 70 TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) line 20 TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) line 100 TestExecutionEngine.OnAfterLastStep() line 21 TestRunner.CollectScenarioErrors() line 78

Hooks Class File

public Hooks(ScenarioContext sc){
  this.sc = sc;
  this.objectContainer = sc.ScenarioContainer.ObjectContainer;
}
 
 [BeforeScenario]
 public InitializeWinAppDriver(){
   this.webDriver = new WindowsDriver<WindowsElement>("{uri of Hub}","{appium options}");
   objectContainer.RegisterInstanceAs<WindowsDriver<WindowsElement>>(webDriver);
   }
  

Step Class private LoginUi loginUiObj;

public LoginStep(ScenarioContext sc){
 this.WebDriver = sc.ObjectContainer.Resolve<WindowsDriver<WindowsElement>>();
 this.loginUiObj - new LogionUi(WebDriver);
}

UI Element Class

  private WindowsDriver<WindowsElement> winAppDriver   
   public LoginUi(WindowsDriver<WindowsElement> driver) =>  winAppDriver = driver;

I have Feature File when I run the test case I get the above exception.

0

There are 0 best solutions below