click/clickAndWait on SalesForce search button randomly causes Kantu to disconnect from the tab (Error #101)


#1

Every so often Kantu will fail to click a button, saying Error #101: Kantu is not connected to a browser tab

What’s odd is that even when I add if ${!statusOK} == false gotoLabel Retry, that will fail as well with the same #101 error.

The search button always has the same ID.

    {
      "Command": "csvRead",
      "Target": "Relevant CSV file",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Name: ${!COL1}, Row: ${!LOOP}",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "Our SF Site",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=phSearchInput",
      "Value": "${!COL1}"
    },
    {
      "Command": "pause",
      "Target": "500",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorIgnore"
    },
    {
      "Command": "label",
      "Target": "Retry",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "id=phSearchButton",
      "Value": ""
    },
    {
      "Command": "if",
      "Target": "${!statusOK} == false",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!statusOK"
    },
    {
      "Command": "gotoLabel",
      "Target": "Retry",
      "Value": ""
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "false",
      "Value": "!errorIgnore"
    }

#2

As a test, if you do a Refresh before the retry, does that help?


#3

Yes, I can refresh manually and restart and it’ll work. I didn’t even think to have Kantu do a refresh, I’ll try that.

Also, what’s confusing is it’ll enter the text in the search box just fine, but won’t click search?


#4

Try the following:

  • Use BringBrowserToForeground to make sure the browser is in the foreground. Browsers only trigger the “onfocus” event when they themselves have the focus. This is a browser thing, and not related to Kantu.

  • If it still does not work, use XClick (id=phSearchInput) + XType (text to search), this will work for sure, as it simulates native mouse and keyboard events.


#5

Okay I’ll try those out as well!

Though, I do prefer to have the macros run in the background. Will xClick take over the mouse to click? Or is it using JS to simulate the mouse click?


#6

Though, I do prefer to have the macros run in the background.

We all do :wink:

…but this means finding a solution with selenium ide commands only. They are using JS to simulate the mouse click - which is also means they don’t always work, and even if they work finding the right xpath can be tricky. But that is true for every selenium tool, not just kantu.

Will xClick take over the mouse to click?

Yes. It does real user simulation and simulates real mouse events. The big advantage is that it always works.

Suggestion:

What we do is to run the xclick kantu macros inside a virtual machine, so we can use xclick and have everything run in the background! Since kantu is cross-platform, a small and free ubuntu virtual box image is sufficient.


#7

Unfortunately they’ve blocked Hyper V and VMs on our work machines. I was able to just use another computer to run them though!

Unrelated, but I looked a lot more into browser automation (something I’ve never done before) and I was wondering if an export to Selenium Webdriver was planned at all?


#8

Selenium webdriver is a good and popular tool but it is somewhat outdated. It does not support new concepts such as computer-vision, text recognition (OCR) and real user simulation. Thus, we can not export Kantu macros in this format.

But an import of Selenium IDE test cases is planned for the near future.


#9

Hey sorry, it looks like I’m actually still getting the same issue.
None of the fixes work for a weird reason - if !${!statusOK} seems to always evaluate to true?
Additionally, even xClick had the same issue.

Here is the snippet:

store | true | !errorIgnore
label | Retry
type | id=phSearchInput | ${projectName}
pause | 100 // This seems to minimize the errors
clickAndWait | id=phSearchButton
if | !${!statusOK}
store | true | !statusOK // Macro never reaches here, even if it encounters an error
refresh
gotoLabel | Retry
endif
store | false | !errorIgnore
clickAndWait | longXPathSelector // This is where it eventually fails

Errors:

[error][ignored] 'clickAndWait' failed. No page load event detected after 10 seconds. Try 'click' instead.

[error][ignored] Error #101: Kantu is not connected to a browser tab // I believe this occures when it gets to the 'if !${!statusOK}

[error] Error #101: Kantu is not connected to a browser tab

Any ideas?


#10

A screencast of the situation would be helpful.


#11

I can’t really screencast, since it’s in SalesForce, and is working on real data.

Which screencast option will let me black out stuff easiest?

Also, I ran this in chrome as well, and got the same error? Was using Firefox before. No idea why it is happening in two browsers.


#12

Never mind, found a solution. I’ll email you the file when I’m done if that is okay?


#13

Thanks for the screencast, that was helpful. As you wrote yourself, it seems the page does not react to the Javascript-level click.

Test: If you replace the the ClickAndWait command with XClick (same locator!), there is a very good chance that this will fix the issue. (Same as @Timo suggested above).