» Specflow – Sharing Steps Between Features Issue
Specflow – Sharing Steps Between Features Issue
|September 15, 2014
Posted by forumadmin
I am breaking down the testing on this so that I have feature files for areas like Login, ResetPassword, ForgotPassword etc. Let’s say I have the below example. I have an automation step creating a brand new user in CreateAccount.feature. That step is used multiple times within that Feature/Step Class without issue. But now I want the user to change their password so I create a new Feature File MyAccount.feature. When I copy the Given Statement in, it is found immediately. Then I add the code to click the reset password and continue on with the rest of the steps.
When I run the ResetPassword test, the automation creates the new user but when it get’s to step 2, “When I Click Reset Password” it fails because it can’t find the element. Since bindings are global, this strikes me odd. So what I did was take step “Given I have created my account” and renamed it and added to the other feature file/steps class and ran it again. It worked fine.
I am not sure why I can’t share between steps. Any ideas?
Some updates showing more code…
scenario: Feature Create Account
Given I have created my account
public class CreateAccount: BaseTestObject
public void Given_I_have_created_my_account()
ConfigProperties.Environment = "Test";
TestDriver.goToUrl(ConfigProperties.StartUrl + "Create/Account");
[followed by input for creating a user acct]
scenario: Feature Change Password
Given I have created my account
When I Click Reset Password
public class MyAccountSteps: BaseTestObject
public void When_I_click_My_Account()
[followed by rest of steps to change password]
More Related Questions
- Specflow how to query database using Linq Context
I am relatively new to .NET and have decided to use BDD in a project. I'm using Specflow for this.
I have created a feature file using the Gherkin format and generated step […]
- Outside-in BDD (with Specflow) I'm new to BDD, but I found it very interesting and want to develop my next project using BDD. After googling and watching screencasts I still have lots of questions about BDD in real […]
- CRUD testing with selenium webdriver I am trying to run tests that will create, edit, and delete entries from a database using a web application. The problem I am having is that the tests are dependent of one another. E.g. I […]
- What is the most mature BDD Framework for .NET? We have been using BDD - Behaviour Driven Development (from Dan North's perspective) as a mechanism to record user acceptance tests and drive development on a couple of projects, with […]
- How to run SpecFlow tests in Visual Studio 2010? Trying to get SpecFlow running with a fresh VS2010 Professional install. Created a new console application and added references to NUnit and SpecFlow. Created a SpecFlow feature. The […]
- Using Specflow with a web service Our C# application architecture involves a web service, a database and a Winforms application.
The winforms application will call a method in the web service called ProcessFile.
I want to […]
- SpecFlow / BDD Examples Just looking for some examples of BDD/SpecFlow - ideally a project so I can see how to use spec flow on big projects where multiple features my reference the same steps etc.
I've read a […]
- XPath questions for Selenium Webdriver C# to locate search result on webpage I am new to Selenium and trying to implement Webjet (www.webjet.com.au) to complete a search process and a flight booking after the search result. However I had difficulties while locating […]
- Selenium: Finding HTML5 list elements From the following html(which is part of a drop down Menu), I need to find the element "Hello World" and click the link
<li data-name="Tools Menu"> <a […]
- C# Webdriver code to wait I have been all the day trying to make:
Wait 10 seconds between two actions in webdriver
Waiting long enough for the element to displayed (the id element) (because in Internet Explorer […]