Created
January 22, 2017 00:57
-
-
Save executeautomation/c52f8094846d95fbb3ebbb47b7062243 to your computer and use it in GitHub Desktop.
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
using NUnit.Framework; | |
using OpenQA.Selenium; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using TechTalk.SpecFlow; | |
using TechTalk.SpecFlow.Assist; | |
namespace SpecflowParallelTest.Steps | |
{ | |
[Binding] | |
public class LoginSteps | |
{ | |
private IWebDriver _driver; | |
public LoginSteps(IWebDriver driver) | |
{ | |
_driver = driver; | |
} | |
[Given(@"I navigate to application")] | |
public void GivenINavigateToApplication() | |
{ | |
_driver.Navigate().GoToUrl("http://executeautomation.com/demosite/Login.html"); | |
} | |
[Given(@"I enter username and password")] | |
public void GivenIEnterUsernameAndPassword(Table table) | |
{ | |
dynamic data = table.CreateDynamicInstance(); | |
_driver.FindElement(By.Name("UserName")).SendKeys((String)data.UserName); | |
_driver.FindElement(By.Name("Password")).SendKeys((String)data.Password); | |
} | |
[Given(@"I click login")] | |
public void GivenIClickLogin() | |
{ | |
Thread.Sleep(1000); | |
_driver.FindElement(By.Name("Login")).Submit(); | |
Thread.Sleep(2000); | |
} | |
[Then(@"I should see user logged in to the application")] | |
public void ThenIShouldSeeUserLoggedInToTheApplication() | |
{ | |
var element = _driver.FindElement(By.XPath("//h1[contains(text(),'Execute Automation Selenium')]")); | |
Assert.Multiple(() => | |
{ | |
Assert.That(element.Text, Is.Null, "Header text not found !!!"); | |
Assert.That(element.Text, Is.Not.Null, "Header text not found !!!"); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment