Correct, keyword tests "Run Script Routine" is exactly that... it recognizes and only runs what it parses out as routines/functions that are parented on the script file itself. Login.Postive and Login.Negitive are methods on the Login object... something not exposed as a script routine.
If you want to execute the code in that way, you can use "Code Snippet" to execute. However, if you want to just execute the Positive and Negative, define them as separate functions within the LoginPage.js like so.
var page = {
form: {
username: Aliases.browser.pageLogin.form.textboxUsername,
password: Aliases.browser.pageLogin.form.textboxPassword,
submitButton: Aliases.browser.pageLogin.form.buttonSubmit
}
}
function Positive(pUsername, pPassword)
{
page.form.username.SetText(pUsername);
page.form.password.SetText(pPassword);
page.form.submitButton.ClickButton();
}
function Negitive(pUsername, pPassword)
{
page.form.username.SetText(pUsername);
page.form.password.SetText(pPassword);
page.form.submitButton.ClickButton();
}
However, that feels redundant... all you REALLY want is a function that does a username/password entry for Login... it's the data that actually determines postive vs. negative and what you do with it. So, to simplify even further:
var page = {
form: {
username: Aliases.browser.pageLogin.form.textboxUsername,
password: Aliases.browser.pageLogin.form.textboxPassword,
submitButton: Aliases.browser.pageLogin.form.buttonSubmit
}
}
function Login(pUsername, pPassword, isPositive = true)
{
page.form.username.SetText(pUsername);
page.form.password.SetText(pPassword);
page.form.submitButton.ClickButton();
if (isPositive) {
//Perform positive validation
}
else {
//Perform negative validation
}
}
This way you call a script routine to execute a test on logging in. You determine, by a boolean parameter, whether the test will check for a positive workflow or a negative workflow. It's all just logging in.