Skip to content

Instantly share code, notes, and snippets.

@testautomationtribe
Created November 16, 2017 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testautomationtribe/8ae64c694254b3d99793c3343177a55f to your computer and use it in GitHub Desktop.
Save testautomationtribe/8ae64c694254b3d99793c3343177a55f to your computer and use it in GitHub Desktop.
Login steps with page object
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using TatAuto.Pages;
using TechTalk.SpecFlow;
namespace TatAuto.Bindings.Steps
{
[Binding]
public class LoginSteps
{
private readonly IWebDriver _driver;
public LoginSteps()
{
_driver = ScenarioContext.Current.Get<IWebDriver>("currentDriver");
}
[Given(@"I Navigate to the Login page")]
public void GivenINavigateToTheLoginPage()
{
_driver.Navigate().GoToUrl("http://127.0.0.1:4001/wordpress/wp-login.php");
}
[When(@"I Login with Username '(.*)' and Password '(.*)' on the Login Page")]
public void WhenILoginWithUsernameAndPasswordOnTheLoginPage(string username, string password)
{
LoginPObject loginPage = new LoginPObject(_driver);
loginPage.LoginAs(username, password);
}
[Then(@"the User Name '(.*)' Should be seen on the Dashboard Page")]
public void ThenTheUserNameShouldBeSeenOnTheDashboardPage(string expectedUser)
{
DashboardPObject dashboardPage = new DashboardPObject(_driver);
Assert.IsTrue(dashboardPage.GetUser().Contains(expectedUser));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment