Powered By Blogger

Search Here!

Wednesday, November 27, 2013

E2E Protractor for .NET

Protractor is an end to end test framework for AngularJS applications built on top of WebDriverJS. In this tutorial I’ll guide you through the process of getting it up and running. Protractor can run Jasmine and Mocha tests so feel free to choose the one that suits your needs best.
The .NET port of Protractor, an end to end test framework for Angular applications.
Protractor for .NET is built on top of Selenium WebDriver C# binding.
Get it from NuGet!
PM> Install-Package Protractor
Supports Microsoft .NET Framework 3.5 and higher..

Write Tests!

         
///
/// User Login.
///

private void UserLogin()
{
//Create Webdriver Instance
webDriver = new ChromeDriver();
webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
IWebDriver ngDriver = new NgWebDriver(webDriver);
//Navigate Browser
ngDriver.Navigate().GoToUrl("https://mail.gmail.com");
//Enter User Name                    ngDriver.FindElement(NgBy.Input("user.Email")).SendKeys("dummy.user@gmail.com");
//Enter User Password
ngDriver.FindElement(NgBy.Input("user.Password")).SendKeys("qwertyuio");
//Wait For Element
webDriver.FindElement(By.CssSelector("button[data-qa-id*='login-button']")).Click();
//Click Save Button
webDriver.FindElement(By.CssSelector("span[class*='ico-profile']")).Click();       
}

No comments:

Post a Comment