Launching from cmd opens multiple Kantu windows

Launching Chrome and Kantu from a .vbs script, passing arguments to the HMTL file produced by testsuites, can lead to multiple Kantu windows opening.

The number of windows is random and so not reproducible: a couple of days ago 4 opened; today 3; last week 2.

The script worked, although the other day it failed several times, making it hard to rule out a cause.

This sounds like some kind of timing issue inside the Kantu launch code. We will try to recreate this.

…although the other day it failed several times,

As a workaround, you can check the macro status and relaunch Kantu if needed. For example script code, please see the run a macro “forever” powershell script.

I considered your suggested workaround yesterday but I’m not sure it’s the optimal solution for my use-case (I’m reading from a csv file and writing to another).

Anyway, if it helps further debugging, some more info…

When the Kantu window opens, multiple messages appear, saying:

“can only run testsuites when it’s not recording or playing”

There must be around 10 of these messages which eventually disappear.

Another issue that may be related (or not - in which case I’m happy to open another post):

My Kantu script opens each URL in a new tab, where it does its business before closing it, and so on.

Sometimes, multiple tabs open with the same page, slowing the script somewhat. At its worst, I’ve seen 8 tabs.

Hope this helps

Hi @admin @TechSupport

This bug is caused from the command

selectWindow | TAB=OPEN | https://newwebsiteURL.com

When it will be solved because it happens that it also opens a large number of tabs in a random way.

Thanks

Hi @admin @TechSupport

To help you to find and fix this bug i add my code.

Today I create this simple macro and run it more times.

{
  "Name": "_test_open",
  "CreationDate": "2019-4-11",
  "Commands": [
    {
      "Command": "bringBrowserToForeground",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "selectWindow",
      "Target": "TAB=OPEN",
      "Value": "https://www.google.com"
    }
  ]
}

First time the macro open 1 tab (correct), after i closed firefox, and reopen firefox after some minutes, I run the same macro and this time opend 4 tabs with the same url (wrong).

I never used loop or others commands.

Sometimes give to the error “Error #101: Kantu is not connected to a browser tab”

I use firefox 66 with Windows 7 and Xmodules free installed.

I hope you can quickly correct these errors that make automation difficult…

Thanks, have a nice day

Can you please retest with V5.0? We made improvements in tab handling that should have solved the issue.

Version 5.2.3 on Ubuntu still has the problem.

Launched from commandline, using attributes direct=1&closeKantu=1&closeBrowser=1&continueInLastUsedTab=1&savelog=eod_log.txt

When executed from UI, macro runs correctly. From shell script it opens 7 chrome instances with 1 being the site and the other six are running UI.vision Kantu

Using macro to login to target site and change to a specific page, and then download several files. When run form UI, all files are downloaded. When run from shell script, macro dies before completion with error: Could not establish connection. Receiving end does not exist.

Macro has 11 lines. Only two of the Kantu sessions appears to have loaded the macro and only one displays the log, although it appears that multiple sessions are writing to the log

Hi! I have a few question for our QA team:

  • Can you please post the shell script that you are using?
  • And what version of Ubuntu are you using?
  • Is it the same issue with Chrome and Firefox?

FYI: You use &closeKantu=1&closeBrowser=1&continueInLastUsedTab=1 but there is a problem with that: continueInLastUsedTab=1 will only work if you do not close the browser (closeBrowser=0) before , as otherwise Chrome/Firefox are closed and there is no tab left to continue in :wink:

To clarify this:

If you make 5 calls:

  • &closeBrowser=0&continueInLastUsedTab=1 - first macro runs
  • &closeBrowser=0&continueInLastUsedTab=1 - second macro continues in same tab
  • &closeBrowser=1&continueInLastUsedTab=1 - third macro continues in same tab, but once this macro is complete, the browser terminates.
  • closeBrowser=1&continueInLastUsedTab=1 - a new browser is launched, thus no previous tab to continue in.
  • &closeBrowser=1&continueInLastUsedTab=1 - again new browser is launched, thus no previous tab to continue in

Update:
Modified attributes to

&closeKantu=0&closeBrowser=0&continueInLastUsedTab=1

Result: No change

Attempted to test in FF and my macro is no longer accessible… so that’s fun… All sorts of issues with file/saving which I’ll attempt to log in separate issues

Ubuntu Version: Ubuntu 18.04.2 LTS

Shell Script:
#!/bin/bash
/opt/google/chrome/chrome http://st.cfnet.loc/storage/EOD.html?direct=1&closeKantu=0&closeBrowser=0&continueInLastUsedTab=1&savelog=eod_log.txt

Contents of EOD.html (with sensitive info removed):

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                <head profile="http://selenium-ide.openqa.org/profiles/test-case">
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="selenium.base" href="" />
                <title>EOD</title>
            </head>
    <body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">EOD</td></tr>
</thead><tbody>

  <tr>
    <td>open</td>
    <td>http://www.somewebsite.com/products/default.aspx</td>
    <td></td>
  </tr>


  <tr>
    <td>type</td>
    <td>id=ctl00_cph1_ls1_txtEmail</td>
    <td>username</td>
  </tr>


  <tr>
    <td>type</td>
    <td>id=ctl00_cph1_ls1_txtPassword</td>
    <td>password</td>
  </tr>


  <tr>
    <td>clickAndWait</td>
    <td>id=ctl00_cph1_ls1_btnLogin</td>
    <td></td>
  </tr>


  <tr>
    <td>open</td>
    <td>http://www.somewebsite.com/myaccount/default.aspx</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[2]/td[3]/input</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[3]/td[3]/input</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[4]/td[3]/input</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[5]/td[3]/input</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[6]/td[3]/input</td>
    <td></td>
  </tr>


  <tr>
    <td>click</td>
    <td>xpath=//*[@id="ctl00_cph1_divQuickLinksContent"]/table/tbody/tr[7]/td[3]/input</td>
    <td></td>
  </tr>

</tbody></table>
<script>
(function() {
  var isExtensionLoaded = function () {
    const $root = document.documentElement
    return !!$root && !!$root.getAttribute('data-kantu')
  }
  var increaseCountInUrl = function (max) {
    var url   = new URL(window.location.href)
    var count = 1 + (url.searchParams.get('reload') || 0)

    url.searchParams.set('reload', count)
    var nextUrl = url.toString()

    var shouldStop = count > max
    return [shouldStop, !shouldStop ? nextUrl : null]
  }
  var run = function () {
    try {
      var evt = new CustomEvent('kantuSaveAndRunMacro', { detail: { html: document.documentElement.outerHTML, storageMode: 'xfile' } })

      window.dispatchEvent(evt)
      setInterval(() => window.dispatchEvent(evt), 1000);

      if (window.location.protocol === 'file:') {
        var onInvokeSuccess = function () {
          clearTimeout(timer)
          clearTimeout(reloadTimer)
          window.removeEventListener('kantuInvokeSuccess', onInvokeSuccess)
        }
        var timer = setTimeout(function () {
          alert('Error #203: It seems you need to turn on *Allow access to file URLs* for Kantu in your browser extension settings.')
        }, 8000)

        window.addEventListener('kantuInvokeSuccess', onInvokeSuccess)
      }
    } catch (e) {
      alert('Kantu Bookmarklet error: ' + e.toString());
    }
  }
  var reloadTimer = null
  var main = function () {
    if (isExtensionLoaded())  return run()

    var MAX_TRY   = 3
    var INTERVAL  = 1000
    var tuple     = increaseCountInUrl(MAX_TRY)

    if (tuple[0]) {
      return alert('Error #204: It seems Kantu is not installed yet - or you need to turn on *Allow access to file URLs* for Kantu in your browser extension settings.')
    } else {
      reloadTimer = setTimeout(function () {
        window.location.href = tuple[1]
      }, INTERVAL)
    }
  }

  main()
})();
</script>
</body>
</html>

I rebuilt the macro for FF and the same thing happens (only worse) - a bunch of FF windows open up and the Macro never seems to start. At least with Chrome the macro attempted to run.

Also tested on Windows… seems better, only launches 2 instances of Kantu - but they still fight each other. Maybe it’s a thread issue.

Hello I had this problem with Kantu For Windows and Firefox 66, after it was never solved (I had also inserted photos in the forum but the problem has never been solved), I changed browser and now use firefox ESR 60 and assign more memory to the operating system , now the problem is solved. I noticed that firefox in some moments of overload can open more windows (it happened to me also by clicking a link).

V5.5.7 same problem. open 2 same tabs at the same time just by one line of cmd
WHY WHY WHY 2020 already

With latest version of RPA and firefox i have NOT this bug.

In the In the past I had this problem but it was solved.

Can you post image o screencash and add OS and browser used please ?

image

Windows 10. So where can I find the internal variable controling selectWindow tab=open

This is another type of error, you must close browser, close rpa and restart browser and rpa.

This is a different bug in my opinion is random.

If you do not close browser and rpa all commands will be errors.

Thanks for you prompt reply. Anyway, I have set a flow control to close the excessive tabs. So it’s not a problem for me at present.~Stay safe

Is it possible to multithread without using command line?

Hi @admin @TechSupport

....},
{
  "Command": "selectWindow",
  "Target": "TAB=OPEN",
  "Value": "https://example.com/create",
  "Description": ""
},
{....

This command opens 1 tab in the first minutes. But after a while it opens double tab. Before long, the kantu browser connection drops.

I’m using the Personal Edition latest version with desktop mode active. What is the cause of this problem?

Thanks