specflow

Feature-scoped step definitions with SpecFlow?

扶醉桌前 提交于 2019-12-29 04:35:08
问题 I'm using SpecFlow to do some BDD-style testing. Some of my features are UI tests, so they use WatiN. Some aren't UI tests, so they don't. At the moment, I have a single StepDefinitions.cs file, covering all of my features. I have a BeforeScenario step that initializes WatiN. This means that all of my tests start up Internet Explorer, whether they need it or not. Is there any way in SpecFlow to have a particular feature file associated with a particular set of step definitions? Or am I

Issue creating RemoteWebDriver instance in C# and SpecFlow

淺唱寂寞╮ 提交于 2019-12-25 12:54:09
问题 I'm banging my head against a wall trying to use a RemoteWebDriver instance in my selenium C# project. Whenever I run my test I get 'Object reference not set to an instance of an object' I started my hub with the following... java -jar "C:\Selenium Grid\selenium-server-standalone-3.4.0.jar" -role hub Started my node with the following... java -Dwebdriver.chrome.driver=C:\WebDrivers\chromedriver.exe -jar "C:\Selenium Grid\selenium-server-standalone-3.4.0.jar" -role webdriver -hub http://10.0

Issue creating RemoteWebDriver instance in C# and SpecFlow

不羁的心 提交于 2019-12-25 12:54:07
问题 I'm banging my head against a wall trying to use a RemoteWebDriver instance in my selenium C# project. Whenever I run my test I get 'Object reference not set to an instance of an object' I started my hub with the following... java -jar "C:\Selenium Grid\selenium-server-standalone-3.4.0.jar" -role hub Started my node with the following... java -Dwebdriver.chrome.driver=C:\WebDrivers\chromedriver.exe -jar "C:\Selenium Grid\selenium-server-standalone-3.4.0.jar" -role webdriver -hub http://10.0

Generating SpecFlow's feature.cs files in a different location to the feature files

主宰稳场 提交于 2019-12-25 04:22:49
问题 Fairly simple one: I'm trying to make SpecFlow generate feature.cs files, but in a directory I specify and not the default (which is the same directory as the associated feature file). Is this possible? 回答1: Not by default, but it might be possible. SpecFlow uses an inbuilt mechanism inside Visual Studio called a custom tool. its a means of automatically performing an action whenever a file changes and is also used in designers (such as the winforms, asp.net etc) which also generate an xxx

Generating specflow stepdefinitions skeleton in f# instead of c#

怎甘沉沦 提交于 2019-12-25 02:26:22
问题 I have been trying to generate f# step definition skeleton file using context menu "Generate Step Definitions" in specflow. But it generates only c#. Is there a way that we tell user preferred language for step definitions. We have most of our acceptance tests written in F# already. Any suggestions are appreciated 回答1: Specflow has some support for F# and it seems that you have a template for generating the definitions when you don't copy them to the clipboard (see Generate step definition

How does specflow handle multiple parameters?

五迷三道 提交于 2019-12-24 17:26:07
问题 As the title says how does specflow handle this x = AddUp(2, 3) x = AddUp(5, 7, 8, 2) x = AddUp(43, 545, 23, 656, 23, 64, 234, 44) The link I gave is how it is usually done. What i want to know is what should the annotation on the top be? [Then(@"What should I write here")] public static void AddUp(params int[] values) { int sum = 0; foreach (int value in values) { sum += value; } return sum; } 回答1: You add parameters by adding single quote marks like this: [When(@"I perform a simple search

Extending StepDefinitions in Specflow

天大地大妈咪最大 提交于 2019-12-24 16:20:38
问题 I trying to experiment with Specflow. So I am writing functional tests for a REST API and have created a couple of step definitions, say CreatePersonStepDefinitions and GetPeopleStepDefinition Those extend CommonStepDefinition , which provides things like: [Given(@"a valid API key is given")] public void AValidApiKeyIsGiven() { ApiKey = "Some Api Key"; } [Then(@"the response HTTP code should be (.*)")] public void ThenTheStatusCodeShouldBe(int statusCode) { Assert.AreEqual (statusCode, (int

Disabling browser javascript with Selenium webdriver + specflow + c# + Pageobject + pagefactory

让人想犯罪 __ 提交于 2019-12-24 11:01:35
问题 I want to disable firefox javascript and run my automated test. I am using Specflow + c# and selenium. I am also using PageObject pattern and Page factory. My feature file goes this way : Scenario: Search for item after disabling the javascript Given I am a ACUST When I disable the javascript And I have entered a text 'dress' string to search for that matches a product Then The relevant search results for the 'dress' will be returned My code is as follows : using System; using System

How to properly indicate which StepArgumentTrasformation to use with step?

≯℡__Kan透↙ 提交于 2019-12-24 07:32:11
问题 I'm trying to transform SpecFlow step arguments to the same return type in two different steps. Here is the simplified feature file: Feature: TransforMe @UseTableToIntsTransform Scenario: First Given I have some condition When I do something Then the results should be | Index | | 1 | | 2 | | 3 | @UseStringToIntsTransform Scenario Outline: Second Given I have some condition When I do something Then the results should contain <expectedResults> Examples: | expectedResults | | 0 | | 0,3,5,7,10 |

What governs when [BeforeScenario] is run in SpecFlow?

杀马特。学长 韩版系。学妹 提交于 2019-12-24 03:29:08
问题 I've recently started on an existing project that uses SpecFlow. I've added a method with [BeforeScenario] in BaseSteps.cs that does some logging. BaseSteps.cs doesn't have a [Binding] attribute on its class, but the derived classes do have [Binding] . However, an example.feature can use steps from different DerivedSteps.cs classes. In these case the [BeforeScenario] is being called multiple times in a single scenario from that feature. Why is this happening? What is calling the