Get help with testing, discuss unit testing strategies etc.


Post by chembali »

I believe I made the 3 changes that you had asked. Here is the updated code.
harness.configure({
    title: 'Sagacity Test Suite',
    runCore: 'sequential',
    autoCheckGlobals:false,
    //needUI:true,
    testClass:Siesta.Test.LoginHelper,
Class('Siesta.Test.LoginHelper', {
   isa: Siesta.Test.ExtJS,
   methods: {
      login: function (callback) {
         this.it('Login', function(t) {
            t.chain(
               {click   : '>> textfield[name=j_username]'},
               {
                  type   : 'jprasad@infogix.com,
                  target   : '>> textfield[name=j_username]'
               },
               {click    : '>> textfield[name=j_password]'},
               {
                  type   : pass,
                  target   : '>> textfield[name=j_password]'
               },
               {
                  click   : '>> button[text=Sign In]',
                  desc   : 'Submit Login'
               },
               if (callback && typeof(callback) === "function") {
                  callback();
               }
            )
         })
      }
    }
});

        t.chain(
{ waitFor : 3000 },
{ login : [] },
Same issue is there. I could not follow the below things

More info how this works here: https://www.bryntum.com/docs/siesta/#!/ ... MethodCall

Or, you can use a function step in the chain and call 'login' method normally.

Sorry. I am new to Siesta and a bit more detailed explanation with sample code will be appreciated. Thank you.

Post by nickolay »

This is not a valid JavaScript syntax:
t.chain(
               {click   : '>> textfield[name=j_username]'},
               {
                  type   : 'jprasad@infogix.com,
                  target   : '>> textfield[name=j_username]'
               },
               {click    : '>> textfield[name=j_password]'},
               {
                  type   : pass,
                  target   : '>> textfield[name=j_password]'
               },
               {
                  click   : '>> button[text=Sign In]',
                  desc   : 'Submit Login'
               },
               if (callback && typeof(callback) === "function") {
                  callback();
               }
            )
         })
You can't put "if" statement inside of the "t.chain()" arguments. Sorry, I can't provide help with regular JavaScript syntax. There's plenty of learning materials online though.
Or, you can use a function step in the chain and call 'login' method normally.
What I mean is:
t.chain(
    { click : '.whatever' },
    
    function (next) {
        t.login(next)
    }
)
A step in the "t.chain()" call can be a plain JS function, in which you call methods of the test class normally.

Post by chembali »

I got the common piece of code working in my environment. Here is the working code.
Class('Siesta.Test.LoginHelper', {
   isa: Siesta.Test.ExtJS,
   methods: {
      login: function (callback) {

        var t = this;
            t.chain(
            {click   : '>> textfield[name=j_username]'},
            {
                  type   : 'asdasasdasd',
                  target   : '>> textfield[name=j_username]'
               },
               {click    : '>> textfield[name=j_password]'},
               {
                  type   : 'kljhfdg3392hsfddkg',
                  target   : '>> textfield[name=j_password]'
               },
               {
                  click   : '>> button[text=Sign In]',
               },
               callback
            )
         }
      }
});
Here is how I am calling it.
 t.chain(
{ waitFor : 3000 },
function (next) { t.login(next) },
Here is one interesting thing. I had tried many different things to get rid of the exception while the starting my tests up. The root cause of that exception happened to be the following.
type   : 'asdasasdasd,
target   : '>> textfield[name=j_username]'
I had missed the ending ' in the the type field. I added it and the exception went away. Good learning for me. I am a server side person, just started looking into this couple of weeks ago. Thank you for your help on this.

Post Reply