Keyword tests are unable to identify functions
Keyword tests are unable to to see function.names. See the code below.
The script is called LoginPage.js
var page = { form: { username: Aliases.browser.pageLogin.form.textboxUsername, password: Aliases.browser.pageLogin.form.textboxPassword, submitButton: Aliases.browser.pageLogin.form.buttonSubmit } } function abc() { Login.Positive("Admin", "123456"); } var Login = { Positive: function(pUsername, pPassword) { page.form.username.SetText(pUsername); page.form.password.SetText(pPassword); page.form.submitButton.ClickButton(); }, Negitive: function(pUsername, pPassword) { page.form.username.SetText(pUsername); page.form.password.SetText(pPassword); page.form.submitButton.ClickButton(); } } function Login() {} Login.Positive = function(pUsername, pPassword) { page.form.username.SetText(pUsername); page.form.password.SetText(pPassword); page.form.submitButton.ClickButton(); } Login.Negitive = function(pUsername, pPassword) { page.form.username.SetText(pUsername); page.form.password.SetText(pPassword); page.form.submitButton.ClickButton(); }
I have two different examples, both with the same outcome. When I try to call Login.Positive in my keyword test or my projects main run, it cannot find the function name. All it can find is Login and ABC.
Help please, I would like to order my scripts this way.
The script is called the page. while the functions are grouped by a common object. For example, the action of login in is a common object with multiple ways to login and multiple ways to test logging in. Hence the object Login. With functions that perform actions around that common object.
If there are better ways to organize my scripts, please let me know.
Exactly... also, prevents the "copy paste" code problem from your original OP... it's really generally bad practice to have the same code showing up almost EXACTLY the same way in multiple places... better to have the code modularized in one spot that is "smart" enough code to do what it needs to no matter where it is called. Again, keep in mind, you're creating building blocks for your testers... if you give them too many blocks that look almost exactly the same, you'll end up with more mistakes as the testers can get easily confused...