unickq/SpecFlow.Selenium.Plugin

Disable close browser

Franclayton opened this issue · 5 comments

Hi!

How to disabling browser closure after scenario finishes?

Thanks

Hey @Franclayton

There is no option to do that now.
What's the case, why do you need that?

Hi!

because using Specflow + Selenium I can close the browser or not using Driver.Quit () in a method annotated with the hook BeforeScenario.

Is it possible to run tests with the --headless option for the browser? Is it possible to add this capability?

Now Driver.Quit() is configured in [TearDown]. So no support of AfterScenario.
What's the case to use this hook?

About headless:
--headless and other options can be passed into capabilities

<autofac>
  <components>
      <component name="YourHeadlessBrowser" type="Unickq.SpecFlow.Selenium.Local.ChromeDriver, Unickq.SpecFlow.Selenium.SpecFlowPlugin" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
        <parameters>
          <parameter name="capabilities">
            <dictionary>
              <item key="arguments" value="--window-size=1900,1050 --headless" />
            </dictionary>
          </parameter>
        </parameters>
     </component>
   </components>
</autofac>

Thank you for your help! The headless one worked perfectly.

About Driver.Quit is the same or the other to leave the browser open for testing and viewing a web interface.

Can you override [TearDown] to not close the browser?

@Franclayton
I think it's possible now without code change.

But you can use Debug mode and configure SpecFlow for debugging and use breakpoints in a generated file to avoid browser quit.

<generator allowDebugGeneratedFiles="true"/>