[APPIUM WINAPP DRIVER[ BoDi.ObjectContainerException : Multiple public constructors with same maximum parameter count are not supported
SpecFlow Version:
- [ ] 3.4
- [ ] 3.3
- [x] 3.1
- [ ] 3.0
- [ ] 2.4
- [ ] 2.3
- [ ] 2.2
- [ ] 2.1
- [ ] 2.0
- [ ] 1.9
Used Test Runner
- [ ] SpecFlow+Runner
- [ ] MSTest
- [x] NUnit
- [ ] Xunit
Version number: 3.12.0
Project Format of the SpecFlow project
- [x] Classic project format using
packages.config - [ ] Classic project format using
<PackageReference>tags - [ ] Sdk-style project format
.feature.cs files are generated using
- [x]
SpecFlow.Tools.MsBuild.GenerationNuGet package - [ ]
SpecFlowSingleFileGeneratorcustom tool
Visual Studio Version
- [x] VS 2019
- [ ] VS 2017
- [ ] VS 2015
Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings
- [ ] Enabled
- [x] Disabled
Are the latest Visual Studio updates installed?
- [ ] Yes
- [x] No, I use Visual Studio version
<Major>.<Minor>.<Patch>16.5.0
.NET Framework:
- [x] >= .NET 4.5
- [ ] before .NET 4.5
- [ ] .NET Core 2.0
- [ ] .NET Core 2.1
- [ ] .NET Core 2.2
- [ ] .NET Core 3.0
- [ ] .NET Core 3.1
- [ ] .NET Core 5.0
Test Execution Method:
- [x] Visual Studio Test Explorer
- [ ] TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
- [ ] Command line – PLEASE SPECIFY THE FULL COMMAND LINE
<SpecFlow> Section in app.config or content of specflow.json
Issue Description
The Issue/Exception occurs when tests are running in parallel mode. Setup Used: Selenium Grid Architecture [HUB & NODE]
Steps to Reproduce
Using Appium/WinAppDriver to automate the Windows Application. The issue occurs when Selenium Grid is used to run the Tests in Parallel Mode.
When the tests are run in Single-mode the exception does not occur.
Note:- When two nodes are setup and are connected to HUB and 2 Scenarios are run, the exception is thrown, however, the issue does not appear when one node is connected to HUB.
Repro Project
https://stackoverflow.com/questions/64465051/appium-winapp-driver-bodi-objectcontainerexception-multiple-public-construct
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.
Added Below Attributes in AssemblyInfo.cs file to run the tests in Parallel mode
[assembly: Parallelizable(ParallelScope.Fixtures)] [assembly: LevelOfParallelism(2)]
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.
It would have helped if you have filled out the issue template. This are all information we need to help you.
@SabotageAndi could you please help me how can i fill the issue template
I pasted it now in the issue description. You can edit it and fill it out.