Get help with testing, discuss unit testing strategies etc.


Post by chembali »

Hi,

The tests cases remain same for both the version, which is same as above attached.

We are pointing to different Siesta versions in 'index.html', I have attached it below. Are we doing it correct, or is there any other changes, which we need to do ?

For Siesta 3.0.2 version, index.html looks like below,

<html>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<head>
<!--
Ext JS library CSS, this is merely for the Siesta UI and is not used by your tests.
Your tests use the ExtJS library, specified in the "preload" config of harness.
DO NOT CHANGE THIS LINE, instead modify the "preload".
-->
<link rel="stylesheet" type="text/css" href="https://cdn.sencha.io/ext/gpl/5.1.0/pack ... sp-all.css">
<link rel="stylesheet" type="text/css" href="../../../../siesta-3.0.2-standard/resources/css/siesta-all.css">

<!--
Ext JS library, this is merely for the Siesta UI and is not used by your tests.
Your tests use the ExtJS library, specified in the "preload" config of harness.
DO NOT CHANGE THIS LINE, instead modify the "preload".
-->
<script type="text/javascript" src="https://cdn.sencha.io/ext/gpl/5.1.0/buil ... "></script>
<script type="text/javascript" src="../../../../siesta-3.0.2-standard/siesta-all.js"></script>

<!-- configure the test harness -->
<script type="text/javascript" src="../../../../suites-common/harness-configure.js"></script>
<script type="text/javascript" src="../../../../suites-common/root-context.js"></script>
<script type="text/javascript" src="../../../../suites-common/login.js"></script>
<script type="text/javascript" src="suite.js"></script>
<script type="text/javascript" src="../../../../suites-common/logout.js"></script>
<script type="text/javascript" src="../../../../suites-common/harness-start.js"></script>
</head>

<body>
</body>
</html>


For Siesta 4.4.3 version, index.html looks like below,

<html>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<head>
<!--
Ext JS library CSS, this is merely for the Siesta UI and is not used by your tests.
Your tests use the ExtJS library, specified in the "preload" config of harness.
DO NOT CHANGE THIS LINE, instead modify the "preload".
-->
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.sencha.io/ext/gpl/5.1.0/pack ... sp-all.css"> -->
<link rel="stylesheet" type="text/css" href="../../../../siesta-4.4.3-standard/resources/css/siesta-all.css">

<!--
Ext JS library, this is merely for the Siesta UI and is not used by your tests.
Your tests use the ExtJS library, specified in the "preload" config of harness.
DO NOT CHANGE THIS LINE, instead modify the "preload".
-->
<!-- <script type="text/javascript" src="https://cdn.sencha.io/ext/gpl/5.1.0/buil ... "></script> -->
<script type="text/javascript" src="../../../../siesta-4.4.3-standard/siesta-all.js"></script>

<!-- configure the test harness -->
<script type="text/javascript" src="../../../../suites-common/harness-configure.js"></script>
<script type="text/javascript" src="../../../../suites-common/root-context.js"></script>
<script type="text/javascript" src="../../../../suites-common/login.js"></script>
<script type="text/javascript" src="suite.js"></script>
<script type="text/javascript" src="../../../../suites-common/logout.js"></script>
<script type="text/javascript" src="../../../../suites-common/harness-start.js"></script>
</head>

<body>
</body>
</html>

Post by nickolay »

Please refer to a Getting Started guide: https://www.bryntum.com/docs/siesta/#!/ ... ng_started for an example of harness file for Siesta 4.4.3

Post by chembali »

Hi,

Thanks for the help.
I also want to know, is there any way we can have dependant test cases in Siesta.
For ex:
Test A depends on Test B.
If Test A fails, I needn't have to execute Test B.
Like in other tools, we have an option like,

@Test (dependsOnMethods = { "Test B" })

public void TestA() {

System.out.println("This will execute second (SignIn)");

}

Thanks in advance..

Post by chembali »

I have narrowed down the problem. Here is my index.html.
<html>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <head>
    <link href="https://bryntum.com/examples/extjs-6.0.1/build/classic/theme-triton/resources/theme-triton-all.css" rel="stylesheet" type="text/css"/>
        
        <link rel="stylesheet" type="text/css" href="../../../../siesta-4.4.3-standard/resources/css/siesta-all.css"> 
        <script type="text/javascript" src="../../../../siesta-4.4.3-standard/siesta-all.js"></script>
        <script type="text/javascript" src="../siesta-coverage-all.js"></script>
        <script type="text/javascript" src="../../../../suites-common/root-context.js"></script>
        <script type="text/javascript" src="index.js"></script>
		
    </head>
	
    <body>
    </body>
</html>
Here is the index.js contained in the above html.
var harness = new Siesta.Harness.Browser.ExtJS()

harness.configure({
    title: 'Sagacity Test Suite',
    runCore: 'sequential',
    autoCheckGlobals:false,
    needUI:true,


    preload     : [
    ],
    alsoPreload: [
        "https://localhost:4000/siesta/webdriver/webdriver.js",
        "https://localhost:4000/siesta/eyes/browser-eyes-selenium.js"
    ],

    loaderPath          : { 'Ext.ux' : '//cdn.sencha.com/ext/gpl/5.1.0/examples/ux' }
});

var tests = [];

tests.push({
    hostPageUrl: context + 'desktop/index.html',
    group: 'Login',
    items: [
        {
            url: '../../../../suites-common/test-scripts/000_sanity.t.js'
        }, {
            url: '../../../../suites-common/test-scripts/001_status.t.js'
        }, {
            separateContext: true,
            url: '../../../../suites-common/test-scripts/010_login.t.js'
        }
    ]
});

tests.push({
    group: 'Preparation-Phase',
    forceDOMVisible: true,
    hostPageUrl: context + 'desktop/index.html',
    preload: [],
    items: [{
        separateContext: true,
        url: 'test-scripts/001_Environment.t.js'
    }
    ]
});

harness.start(tests);
// eof Harness.start
The 001_Environment.t.js test case is failing for me. Here is the code for 001_Environment.t.js.
describe('Automate create of first environment in the admin screen', function(t) {

    t.it('Navigate to Environment and create new environment',function(t){

        t.chain(

				{ waitForCQ   : 'tabpanel'},

				{ moveCursorTo : "#contentRegion igx-maintoolbar [itemId=menuButton] => .x-btn-icon-el", offset : [7, 6] },

				{ waitFor : "Target" , args : "[itemId=adminButtons] => .x-menu-item-text" },

				{ waitFor: 2000},
				
				{ moveCursorTo : "[itemId=adminButtons] => .x-menu-item-text", offset : [29, 16] },
				
				{ waitFor: 3000},
				{ waitFor : "Target" , args : "menuitem[text=Environments] => .x-menu-item-text" },

				{ click : "menuitem[text=Environments] => .x-menu-item-text", offset : [26, 12] },

				{ action : "click", target : "#contentRegion igx-listdevenvview panel igx-addbutton[text=New] => .x-btn-button", offset : [18, 2] },

				
				{ action : "type", text : "SAGA_DEV" },

				 { waitFor: 3000}, 

				{ click : "#contentRegion igx-listdevenvview panel igx-editdevenv [itemId=devEnvTabPanel] panel[title=Details] form panel fieldcontainer[fieldLabel=Retention Period] [itemId=period] => .x-form-text", offset : [53, 13] },

				{ click : "#contentRegion igx-listdevenvview panel igx-editdevenv [itemId=devEnvTabPanel] panel[title=Details] form panel fieldcontainer[fieldLabel=Retention Period] [itemId=period] => .x-form-spinner-up", offset : [19, 7] },

				{ click : "#contentRegion igx-listdevenvview panel igx-savebutton[text=Save] => .saveButton", offset : [13, 10] },
				
				{ waitFor : "Target" , args : "[itemId=ok] => .x-btn-button" },

				{ click : "[itemId=ok] => .x-btn-button", offset : [37, 2] }

            )
        }
    )


}
)

The above test case requires the home page ( after successful login ) to be displayed. But the login.t.js test case mentioned in the harness works fine and it logs the user in successfully. But after the completion of the test case, the login page is displayed again causing the next test case ( new environment creation ) to fail. The login test case is shown below.
StartTest(function(t) {
  var cs = {
    ms: { username: 'msurowka@infogix.com', password: 'sss' },
    sl: { username: 'slorenc@infogix.com', password: 'ddfdff' },
    cw: { username: 'cwoo@infogix.com', password: 'gfgfggf' },
    jp: { username: 'jprasad@infogix.com', password: 'ggfhghghghgh' }
  };
  var credentials = cs.jp;

  t.waitForCQ('#loginView panel form textfield[name=j_username]', function(username) {
    t.type(username[0], credentials.username, function(next) {
      t.waitForCQ('#loginView panel form textfield[name=j_password]', function(password) {
        t.type(password[0], credentials.password, function(next) {
          t.click('button[text=Sign In] => .x-btn-inner', function(next) {
            t.done();
          });
        });
      });
    });
  });
});

I am stuck and frustrated. Any help would be greatly appreciated.

Post by nickolay »

There's no dependencies between tests in Siesta, every test should be self-contained. If you want to share some functionality between tests, you can write new test methods, as described here: https://www.bryntum.com/docs/siesta/#!/ ... test_class

Post by chembali »

This is helpful. The above test works just fine when run from the Siesta UI. The issue exists when it is run using automation.

Post by nickolay »

This means there's probably some race condition in the test. Hard to say more precisely w/o reproducible test case.

Post by chembali »

I included the login process in my 'create environment' test case and it is working now. Thank you for your help on this.
Now I am trying to create a reusable login method using the 'testClass' option and it is not working for me.
Here is my new class file that is included.
Class('SagacityLoginClass', {
   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'
               }
            )
         })
      }
    }
});
I have included the testClass in the harness as shown below.

harness.configure({
    title: 'Sagacity Test Suite',
    runCore: 'sequential',
    autoCheckGlobals:false,
    needUI:true,
    testClass:'SagacityLoginClass'

I am calling the above class in my test script as shown below.
describe('Automate create of first environment in the admin screen', function(t) {

    t.it('Navigate to Environment and create new environment',function(t){

        t.chain(
		        {  t.login() },
			{ waitForCQ   : 'tabpanel'},
Any idea why it is not working?

Post by chembali »

I am getting the following error while starting the test.

[DEBUG] Dispatcher start
[DEBUG] Runner setup: a Siesta.Launcher.Runner.WebDriverNodeJS
[DEBUG] Dispatcher setup starting
[DEBUG] Trying to create a WebDriver instance for browser: internet explorer
[DEBUG] WebDriver instantiated successfully
[DEBUG] PageId: 1, method : getConfigInfo starting, args size: 16
[DEBUG] PageId: 1, method : getConfigInfo, took 0.094s, result size : 967
[DEBUG] Dispatcher setup completed, launching the suite
Launching test suite, OS: Windows, browser: IE 11.0
[DEBUG] Launch runner, pagesCount: 1, max : 1, pages left: 1
[DEBUG] PageId: 1, method : launchAutomatedTests starting, args size: 437
[DEBUG] PageId: 1, method : launchAutomatedTests, took 0.383s, result size : 4
[DEBUG] Page polling has started
[DEBUG] PageId: 1, method : getAutomationState starting, args size: 2
[DEBUG] PageId: 1, method : getAutomationState, took 0.087s, result size : 1753
[WARN] [ERROR] message : Object doesn't support this action
[WARN] [ERROR] url : https://isrhel1.infogix.com:4000/siesta/ ... sta-all.js
[WARN] [ERROR] line : 17833
[WARN] [ERROR] col : 13
[WARN] [ERROR] stack : TypeError: Object doesn't support this action
at methods.processURL (https://isrhel1.infogix.com:4000/siesta/ ... s:17833:13)
at override (https://isrhel1.infogix.com:4000/siesta/ ... .js:817:13)
at methods.runCoreSequential (https://isrhel1.infogix.com:4000/siesta/ ... s:17526:17)
at override (https://isrhel1.infogix.com:4000/siesta/ ... .js:817:13)
at Anonymous function (https://isrhel1.infogix.com:4000/siesta/ ... s:44161:21)
at methods.runCoreParallel (https://isrhel1.infogix.com:4000/siesta/ ... s:17474:25)
at override (https://isrhel1.infogix.com:4000/siesta/ ... .js:817:13)
at Anonymous function (https://isrhel1.infogix.com:4000/siesta/ ... s:44159:17)
at processGroup (https://isrhel1.infogix.com:4000/siesta/ ... s:44199:78)
at methods.runCoreSharedContext (https://isrhel1.infogix.com:4000/siesta/ ... s:44206:13)

Post by nickolay »

1) "testClass" should receive an actual class constructor, not a string (need to remove the quotes)
2)
{  t.login() },
is not a valid syntax, valid one would be:
{ login : [] }
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.

3) In the "login" method you need to call the "callback" argument (you can provide it as a last step in the inner chain).

Post Reply