-
-
Save testautomationtribe/a0f210dec858f54fd085d1a073912a00 to your computer and use it in GitHub Desktop.
Login page object with specflow
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; | |
namespace TatAuto.Pages | |
{ | |
public class LoginPObject | |
{ | |
[FindsBy(How = How.Id, Using = "user_login")] | |
protected IWebElement UsernameTxtBox { get; set; } | |
[FindsBy(How = How.Id, Using = "user_pass")] | |
protected IWebElement PasswordTxtBox { get; set; } | |
[FindsBy(How = How.Id, Using = "wp-submit")] | |
protected IWebElement LoginBtn { get; set; } | |
private readonly IWebDriver _driver; | |
public LoginPObject(IWebDriver driver) | |
{ | |
_driver = driver; | |
PageFactory.InitElements(_driver, this); | |
} | |
/// <summary> | |
/// Login | |
/// </summary> | |
/// <param name="username"></param> | |
/// <param name="password"></param> | |
/// <returns></returns> | |
public DashboardPObject LoginAs(string username, string password) | |
{ | |
UsernameTxtBox.SendKeys(username); | |
PasswordTxtBox.SendKeys(password); | |
LoginBtn.Click(); | |
return new DashboardPObject(_driver); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment