Feature: Login to the website
As a user
I want to login to the website
So that I can access my account
Scenario: Successful login
Given I am on the login page
When I enter valid username and password
Then I should be redirected to the home page
// Step definition
using TechTalk.SpecFlow;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
[Binding]
public class LoginSteps
{
private IWebDriver driver;
[Given(@"I am on the login page")]
public void GivenIAmOnTheLoginPage()
{
driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.example.com/login");
}
[When(@"I enter valid username and password")]
public void WhenIEnterValidUsernameAndPassword()
{
// code to enter username and password
}
[Then(@"I should be redirected to the home page")]
public void ThenIShouldBeRedirectedToTheHomePage()
{
// code to verify redirection
driver.Quit();
}
[BeforeTestRun]
public static void BeforeTestRun()
{
var configuration = new SpecFlow.Configuration.SpecFlowConfiguration();
configuration.Plugins.Add(new SpecFlow.Cucumber.Reports.CucumberReportPlugin(
new SpecFlow.Cucumber.Reports.Configuration
{
OutputFolder = "cucumber-reports"
}));
}
}
No comments:
Post a Comment