This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: UserAccountFeature | |
In order to be able to use the site | |
As a user | |
I want to be able to manage my account | |
Scenario: User can register to use the site | |
Given I am on the register page | |
And I have entered a Username of 'johnmmoss' and a password of 'P@ssword123' | |
When I press register | |
Then a new account is created with a username of a Username of 'johnmmoss' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Binding] | |
public class UserAccountSteps | |
{ | |
[Given(@"I am on the register page")] | |
public void GivenIAmOnTheRegisterPage() | |
{ | |
var homePage = ScenarioContext.Current.Get<HomePage>(); | |
var registerPage = homePage.GoToRegisterPage(); | |
ScenarioContext.Current.Set(registerPage); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IWebDriver driver = new FirefoxDriver(); | |
FeatureContext.Current.Set(driver); | |
driver.Navigate().GoToUrl(Url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomePage | |
{ | |
private readonly IWebDriver webDriver; | |
protected static string BaseUrl = ConfigurationManager.AppSettings["WebsiteUrl"]; | |
public HomePage(IWebDriver webDriver) | |
{ | |
this.webDriver = webDriver; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[BeforeFeature()] | |
public static void BeforeFeature() // must be static | |
{ | |
// Create the webdriver and store it in the feature context | |
IWebDriver driver = new FirefoxDriver(); | |
FeatureContext.Current.Set(driver); | |
driver.Navigate().GoToUrl(Url); | |
// Empty the database ready for the tests | |
using (var context = new SpecflowTestContext()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var trElements = webDriver.FindElements(By.ClassName("tr-content")); | |
var result = new List<List<string>>(); | |
foreach (var trElement in trElements) | |
{ | |
var row = new List<string>(); | |
foreach (var tdElement in trElement.FindElements(By.ClassName("td-content"))) | |
{ | |
row.Add(tdElement.Text); | |
} | |
result.Add(row); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find the submit button and click it | |
webDriver.FindElement(By.Id("CreateButton")).Click(); | |
// Find the form by its tag and submit it | |
webDriver.FindElement(By.TagName("form")).Submit(); | |
// Call submit on the element, it automatically submits the form | |
var descriptionElement = webDriver.FindElement(By.Id("Name")); | |
descriptionElement.Clear(); | |
descriptionElement.SendKeys(description); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Click the a link of the tr where a td has a value of "Leeds", and the a link has the text "Edit" | |
var name = "Leeds"; | |
var xpath = string.Format("//tr[td[normalize-space(text())='{0}']]/td/a[normalize-space(text()) = \"Edit\"]", name); | |
var editLink = webDriver.FindElement(By.XPath(xpath)); | |
editLink.Click(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if the provided value exists in an html table cell | |
public bool RowExists(string value) | |
{ | |
try | |
{ | |
var rowXPath = string.Format("//tr[td[normalize-space(text())='{0}']]", value); | |
webDriver.FindElement(By.XPath(rowXPath)); | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITimesheetsContext _context = MockRepository.GenerateStub<ITimesheetsContext>(); | |
_context.Departments = new TestDbSet<Department>(); | |
_context.Timesheets = new TestDbSet<Timesheet>(); | |
_context.Employees = new TestDbSet<Employee>(); | |
_context.Stub(c => c.SaveChangesAsync()).Return(Task.FromResult(0)); |