Command Line API SelectWindow Command Bug

When running a folder through the command line API, my macro fails when selecting the second tab that pops up (SelectWindow | tab=1). I always receive the following error, “Error: Invalid tab ID: 1.”

When I just run the folder inside of Ui.Vision, and not through the command line, the script works perfectly. Why is that? Please help.

Can you please add a screencast for this? I made a test with the DemoTab macro. I put it in a folder and started it with this batch file:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///D:/test/ui.vision.html?folder=a&direct=1&closeRPA=0&savelog=log1.txt"

=> all worked ok

t1

Macro:

{
  "Name": "DemoTabs1",
  "CreationDate": "2020-5-1",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/demo/tabs",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "linkText=Open new web page in new browser tab",
      "Value": ""
    },
    {
      "Command": "selectWindow",
      "Target": "tab=1",
      "Value": ""
    },
    {
      "Command": "assertTitle",
      "Target": "*1* TAB1",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=sometext1",
      "Value": "this is tab 1"
    },
    {
      "Command": "click",
      "Target": "linkText=Open yet another web page in a new browser tab",
      "Value": ""
    },
    {
      "Command": "selectWindow",
      "Target": "tab=2",
      "Value": ""
    },
    {
      "Command": "assertTitle",
      "Target": "*2* TAB2",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=sometext2",
      "Value": "And this is tab 2!"
    },
    {
      "Command": "selectWindow",
      "Target": "tab=1",
      "Value": ""
    },
    {
      "Command": "assertTitle",
      "Target": "*1* TAB1",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=sometext1",
      "Value": "Now back in tab 1 - test done!"
    },
    {
      "Command": "comment",
      "Target": "We can also open new tabs",
      "Value": ""
    },
    {
      "Command": "selectWindow",
      "Target": "tab=open",
      "Value": "https://ui.vision"
    },
    {
      "Command": "selectWindow",
      "Target": "tab=open",
      "Value": "https://ocr.space"
    },
    {
      "Command": "type",
      "Target": "id=imageUrl",
      "Value": "UI.Vision RPA Tab Test done"
    }
  ]
}

I found the solution of why the Command Line API loses its count when another Tab opens from a button click. In the beginning of my code, I have the open command to sign into my site, and that brings up 2 Tabs (Tab 0 and Tab 1). The Tab where my actual site is in that I want to test is in Tab 1, so once I do “SelectWindow | tab=1” I delete Tab 0 with command, “SelectWindow | TAB=CLOSEALLOTHER”.

Because I removed Tab 0, so I can only have 1 Tab open (the actual site tab), when it was time to click a button to bring up my new second tab, Ui.Vision seemed like it lost its count.

Solution: I kept the 2 Original Tabs (Tab 0 and Tab 1) from signing into the site, and clicked the button so there will be 3 Tabs. This way Ui.Vision did not lose it count and I was able to click inside of Tab 3. Overall, if I keep all of my tabs, and not remove any, then it works.