Code: Select all
namespace HondaAutosTest
{
/// <summary>
/// Checks for URL that requires login and performs login sequence.
/// </summary>
[TestModule("5FED145A-A1EB-4AAD-A7E1-FC291B85C6ED", ModuleType.UserCode, 1)]
public class Login : ITestModule
{
string _BrowserName = ""; // gets name of the opened browser
public string BrowserName
{
get { return _BrowserName; }
set { _BrowserName = value; }
}
string _Environment = ""; // gets url of the environment
public string Environment
{
get { return _Environment; }
set { _Environment = value; }
}
/// <summary>
/// Constructs a new instance.
/// </summary>
public Login()
{
// Do not delete - a parameterless constructor is required!
}
/// <summary>
/// Performs the playback of actions in this module.
/// </summary>
/// <remarks>You should not call this method directly, instead pass the module
/// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
var repo = HondaAutosTestRepository.Instance;
Report.Log(ReportLevel.Info, Environment);
// test for environment as some do not need a login
if (Environment == "https://staging" || Environment == "https://pat" || Environment == "https://release") {
// test for which browser is open in order to sign in properly
switch (BrowserName) {
case "chrome":
//repo.Chrome.ServerSignIn.Username.Element.SetAttributeValue("Text", "username);
//repo.Chrome.ServerSignIn.Password.Element.SetAttributeValue("Text", "password");
//repo.Chrome.ServerSignIn.SignIn.Click();
repo.Chrome.ServerSignIn.Username.Click("150;10");
repo.Chrome.ServerSignIn.Username.EnsureVisible();
Keyboard.Press("username");
repo.Chrome.ServerSignIn.Password.Click("150;10");
repo.Chrome.ServerSignIn.Password.EnsureVisible();
Keyboard.Press("password");
repo.Chrome.ServerSignIn.SignIn.Click("35;15");
break;
case "firefox":
repo.Firefox.ServerSignIn.Username.Element.SetAttributeValue("Text", "username);
repo.Firefox.ServerSignIn.Password.Element.SetAttributeValue("Text", "password");
repo.Firefox.ServerSignIn.SignIn.Click();
break;
// edge does not work on Windows Server 2016
// case "edge":
// repo.Edge.ServerSignIn.Username.Element.SetAttributeValue("Text", "username");
// repo.Edge.ServerSignIn.Password.Element.SetAttributeValue("Text", "password");
// repo.Edge.ServerSignIn.SignIn.Click();
// break;
// there is an open ticket that prevents the vehicle drop down from working
// case "IE":
// repo.IE.Username.Element.SetAttributeValue("Text", "username");
// repo.IE.Password.Element.SetAttributeValue("Text", "password");
// repo.IE.SignIn.Click();
// break;
case "default":
Report.Log(ReportLevel.Failure, "Browser was not found on system. Allowed browsers are Chrome, Edge (Chromium), Firefox or IE.");
break;
}
} Delay.Seconds(5);
}