-
-
Save pdelre/30f5b21350d844c8a326 to your computer and use it in GitHub Desktop.
SpecFlow Hello World
This file contains 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: SpecFlowFeature1 | |
I want to be able to go to google.com | |
Scenario: Go to google.com | |
When I navigate to google.com | |
Then I should go to google.com |
This file contains 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
using System; | |
using TechTalk.SpecFlow; | |
using NUnit.Framework; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Firefox; | |
namespace SpecFlow | |
{ | |
[Binding] | |
public class SpecFlowFeature1Steps | |
{ | |
[When(@"I navigate to google\.com")] | |
public void WhenINavigateToGoogle_Com() | |
{ | |
WebBrowser.Current.Navigate().GoToUrl("http://google.com"); | |
} | |
[Then(@"I should go to google\.com")] | |
public void ThenIShouldGoToGoogle_Com() | |
{ | |
Assert.That(WebBrowser.Current.Url, Is.SamePath("http://www.google.com")); | |
} | |
} | |
} |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using TechTalk.SpecFlow; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Firefox; | |
namespace SpecFlow | |
{ | |
[Binding] | |
class WebBrowser | |
{ | |
public static IWebDriver Current | |
{ | |
get | |
{ | |
if (!ScenarioContext.Current.ContainsKey("browser")) | |
{ | |
ScenarioContext.Current["browser"] = new FirefoxDriver(); | |
} | |
return ScenarioContext.Current.Get<IWebDriver>("browser"); | |
} | |
} | |
[AfterScenario] | |
public static void Quit() | |
{ | |
if (ScenarioContext.Current.ContainsKey("browser")) | |
{ | |
Current.Quit(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment