Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: Selenium Manager is not working with .NetCore Project having Specflow.Specrun as runner. #11419

Closed
miaskadu opened this issue Dec 13, 2022 · 7 comments

Comments

@miaskadu
Copy link

What happened?

Hello,

I have recently tried using Selenium Manager which downloads matching driver based on Chrome Installed without using any external library. But it does not work for me using .Net 3.1 Project having Specflow.Specrun as runner, it works perfectly with Specflow.Nunit & Specflow.Xunit.

Problem with Specflow.Nunit & Specflow.Xunit is that it does not support Default.srprofile setting due to which retry & parallel execution will stop working.

Can someone suggest any alternative solution to this?

How can we reproduce the issue?

1. Create .netCore 3.1 Project with Specflow choosing Specflow+Runner.
2. Add Selenium 4.6.0 Nuget Package
3. Try to initialize Driver.

Relevant log output

Message: 
Exception has been thrown by the target of an invocation. -> The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html.

      Stack Trace: 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html.
DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
ChromeDriverService.CreateDefaultService()
ChromeDriver.ctor(ChromeOptions options)
Driver.Initialize(Browser browser, Application application) line 98
LaunchBrowser.ctor() line 14
   --- End of inner exception stack trace ---
RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
<13 more frames...>
RunnerTestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments, TimeSpan& duration)
TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) line 481
TestExecutionEngine.OnAfterLastStep() line 234
RunnerTestExecutionEngine.OnAfterLastStep()
TestRunner.CollectScenarioErrors() line 60
CWHomeHealthFeature.ScenarioCleanup()
CWHomeHealthFeature.ClinicalWeb_AdmitAHHPatient() line 23
StaticOrInstanceMethodExecutor.ExecuteInternal(ITestThreadExecutionContext testThreadExecutionContext)
StaticOrInstanceMethodExecutor.Execute(ITestThreadExecutionContext testThreadExecutionContext)
TestNodeTask.Execute()

Operating System

Windows 10

Selenium version

4.6.0

What are the browser(s) and version(s) where you see this issue?

Chrome - 108.0.5359.99

What are the browser driver(s) and version(s) where you see this issue?

Chrome - 108.0.5359.99

Are you using Selenium Grid?

No response

@github-actions
Copy link

@miaskadu, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@bonigarcia
Copy link
Member

@miaskadu Can you try with Selenium Manager 4.7.0, please?

@miaskadu
Copy link
Author

miaskadu commented Dec 13, 2022 via email

@bonigarcia
Copy link
Member

bonigarcia commented Dec 13, 2022

I am not an expert in .Net, but I tried the following and it works as expected:

.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Selenium.WebDriver" Version="4.7.0" />
  </ItemGroup>

</Project>

.cs

using System;
using OpenQA.Selenium.Chrome;

 namespace Example {
     static class BasicSelenium {
          [STAThread]
          static void Main()
          {
               var driver = new ChromeDriver();
               driver.Quit();
          }

     }
}

shell

> dotnet run

Starting ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}) on port 57120
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

DevTools listening on ws://127.0.0.1:57123/devtools/browser/96f3506f-8a05-4ac8-a815-ee29c1f73af1

@miaskadu Maybe you can provide a running piece of code to try to reproduce the issue.

@miaskadu
Copy link
Author

miaskadu commented Dec 14, 2022

Problem occurs when you use Specflow+Runner Project. Please find below step to create Specflow Project

  1. Step I

image

  1. Step II

image

  1. Step III

image

  1. Please find the below Project Zip which only focus on driver launch & it is not happening.

SeleniumManagerWithSpecflowProject.zip

@titusfortner
Copy link
Member

You apparently need a specflow account to run this code, so we can't duplicate it.

If it is working with some Specflow products and not others, I suggest raising the issue with Specflow devs.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants