Need to Close Existing Tabs

The macros I’ve created involve clicking buttons that create multiple tabs, which seems to be problematic for two reasons:

  1. When using SeeShell Browser app: clicking play on a new macro always defaults to the first tab if there’s multiple open. I want my macro to run on the selected tab, which ends up be the last tab on the. There’s no UI or hotkey to close tabs

  2. When using the APIs: Unlike the browser app, each subsequent macro plays on the selected tab (which is good), but seems to fail playing macros once I get to a 4th tab, and times out (Error code: -1)

Can you advise how to close existing tabs via SeeShell browser, API, and/or macro command?

2 Likes
  1. By design all tabs are closed at a (manual) replay start to start with a clean slate. Once we have the “CloseAllOtherTabs” feature (see below) this will change. Because then users can decide per macro command if they want to have the tabs closed at replay start.

  2. Api “4th tab error” => I forwarded this to development and will report back. But in any case, the new features of the September update will solve this (see below).

  3. Currently the only way to close tabs via API is the brute force way of closing and reopening the browser.

Here is the good news:

Tab management (switching tabs, opening tabs and “CloseAllOtherTabs”) is part of the upcoming September update, which will be available in early October. In a nutshell, this means that SeeShell will have the same features that Kantu already has with the selectWindow command:

1 Like

Thanks, looking forward to the update.

If I need to have something working now and wanted to follow approach #3, is there a way to copy the URL before closing the browser, and then open that URL upon reopening the browser?

In my case, a unique URL is created each time I run the test.

This is a good idea! :slight_smile: => Extracting the URL can be one with a litte Javascript snippet and Javascript command plus the ExtractAdd command:

In the first macro,

  • extract the website URL with Javascript: var url = window.location.href ; return url;
  • return this info to the calling script with ExtractAdd | ${!JSRESULT}

extractadd

In the calling script you can use the GetExtractImageData API to retrieve this info. Then, before starting the second macro, use setVariable (“starturl”, data(0)) to define a variable, which you can then reference in the SeeShell open command: Open | ${starturl}

So in the second macro,

  • use the open command: Open | ${starturl}

starturl

Below is the complete VBS script that combines the two macros. I used WebScraping-Data-Extraction.vbs as a starting point. I uploaded the new script and the TestTab1/TestTab2 macros to the SeeShell Github repo: Extract URL. I used SeeShell - Tab Management - Test Page as test page.

option Explicit

dim myBrowser, i, s, allData, data, line

set myBrowser = CreateObject ("seeshell.browser")

i = myBrowser.open(true)


i = myBrowser.echo ("first macro")
i = myBrowser.Play("testtab1")

if i < 0 then msgbox "Error playing macro: " + cstr(i) + vbCrLf + vbCrLf +"Text: "+myBrowser.getLastError()

'Get URL 
allData = myBrowser.GetExtractImageData()

'The data is separated by [DATA] for each EXTRACTADD command
data = Split(allData, "[DATA]")
msgbox "Next macro will use this URL: " +data(0)  'FIRST element has index = 0

'Restart SeeShell (optional)
i = myBrowser.close()
i = myBrowser.open(true)

i = myBrowser.setVariable ("starturl", data(0))

i = myBrowser.play("TestTab2")
if i < 0 then msgbox ("Play error: " + cstr (i) +" " +myBrowser.getLastError())		

msgbox ("Press OK to close the SeeShell Browser.")
i = myBrowser.close()

WScript.Quit(i)

SeeShell V3.3 and later have now the TAB command.

Now you can use, for example, the following sequence:

  • TAB | Switch to 0 (goes back to the left tab)
  • TAB | CLOSEALLOTHER (closes all other tabs)

With today’s update Kantu can close existing tabs with selectWindow | tab=close :slight_smile: