Last active
March 23, 2019 17:25
-
-
Save pragmatictesters/01003faf3b3e2c8019c1e4e31fec37bd to your computer and use it in GitHub Desktop.
Selenium WebDriver C# : Login Page
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 OpenQA.Selenium; | |
using OpenQA.Selenium.Support.PageObjects; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ISMDemoApplication | |
{ | |
class LoginPage | |
{ | |
//public LoginPage(IWebDriver driver)=> PageFactory.InitElements(driver, this); | |
public LoginPage(IWebDriver driver) | |
{ | |
PageFactory.InitElements(driver, this); | |
} | |
[FindsBy(How = How.CssSelector, Using = "#UserName")] | |
public IWebElement txtUsername { get; set; } | |
[FindsBy(How = How.CssSelector, Using = "#Password")] | |
public IWebElement txtPassword { get; set; } | |
[FindsBy(How = How.CssSelector, Using = ".btn-login > .btn-cnt")] | |
public IWebElement btnLogin { get; set; } | |
[FindsBy(How = How.CssSelector, Using = ".validation-summary-errors span")] | |
public IWebElement errValidation { get; set; } | |
public LoginPage typeUsernme(string username) | |
{ | |
txtUsername.SendKeys(username); | |
return this; | |
} | |
public LoginPage typePassword(string password) | |
{ | |
txtPassword.SendKeys(password); | |
return this; | |
} | |
public LoginPage clickLoginFailure() | |
{ | |
btnLogin.Click(); | |
return this; | |
} | |
public string getValidationError() | |
{ | |
return errValidation.Text; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is used for Pragmatic Training