The macros I’ve created involve clicking buttons that create multiple tabs, which seems to be problematic for two reasons:
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
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?
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.
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).
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:
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! => 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}
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}
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)