Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LoginTests
- {
- [TestInitialize]
- public void Init()
- {
- Driver.Initialize();
- }
- [TestMethod]
- public void Admin_User_Can_Login()
- {
- LoginPage.GoTo();
- LoginPage.LoginAs("admin").WithPassword("1234").Login();
- }
- [TestCleanup]
- public void Clean()
- {
- Driver.Instance.Close();
- }
- }
- namespace JuiceShopAutomation
- {
- public class LoginPage
- {
- public static void GoTo()
- {
- Driver.Instance.Navigate().GoToUrl("www.google.com");
- //var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(60));
- //wait.Until(d => d.SwitchTo().ActiveElement().GetAttribute("id") == "userEmail");
- }
- public static LoginCommand LoginAs(string userName)
- {
- return new LoginCommand(userName);
- }
- }
- public class LoginCommand
- {
- private readonly string userName;
- private string password;
- public LoginCommand(string userName)
- {
- this.userName = userName;
- }
- public LoginCommand WithPassword(string password)
- {
- this.password = password;
- return this;
- }
- public void Login()
- {
- var loginInput = Driver.Instance.FindElement(By.Id("userEmail"));
- loginInput.SendKeys(userName);
- var passwordInput = Driver.Instance.FindElement(By.Id("userPassword"));
- passwordInput.SendKeys(password);
- var loginButton = Driver.Instance.FindElement(By.Id("loginButton"));
- loginButton.Click();
- }
- }
- }
Add Comment
Please, Sign In to add comment