func (auto *AutoGcd) GetTab() (*Tab, error) {
	auto.tabLock.RLock()
	defer auto.tabLock.RUnlock()
	for _, tab := range auto.tabs {
		if tab.Target.Type == "page" {
			return tab, nil
		}
	}
	return nil, &InvalidTabErr{Message: "no Page tab types found"}
}
Returns the first "visual" tab.
package autogcd
import (
	"errors"
	"fmt"
	"os"
	"sync"
	"github.com/wirepair/gcd"
)
type AutoGcd struct {
	debugger *gcd.Gcd
	settings *Settings
	tabLock  *sync.RWMutex
	tabs     map[string]*Tab
	shutdown bool
}
func NewAutoGcd(settings *Settings) *AutoGcd {
	auto := &AutoGcd{settings: settings}
	auto.tabLock = &sync.RWMutex{}
	auto.tabs = make(map[string]*Tab)
	auto.debugger = gcd.NewChromeDebugger()
	auto.debugger.SetTerminationHandler(auto.defaultTerminationHandler)
	if len(settings.extensions) > 0 {
		auto.debugger.AddFlags(settings.extensions)
	}
	if len(settings.flags) > 0 {
		auto.debugger.AddFlags(settings.flags)
	}
	if settings.timeout > 0 {
		auto.debugger.SetTimeout(settings.timeout)
	}
	if len(settings.env) > 0 {
		auto.debugger.AddEnvironmentVars(settings.env)
	}
	return auto
}
func (auto *AutoGcd) defaultTerminationHandler(reason string) {
	fmt.Printf("chrome was terminated: %s\n", reason)
}
func (auto *AutoGcd) SetTerminationHandler(handler gcd.TerminatedHandler) {
	auto.debugger.SetTerminationHandler(handler)
}
func (auto *AutoGcd) Start() error {
	if auto.settings.connectToInstance {
		auto.debugger.ConnectToInstance(auto.settings.chromeHost, auto.settings.chromePort)
	} else {
		auto.debugger.StartProcess(auto.settings.chromePath, auto.settings.userDir, auto.settings.chromePort)
	}
	tabs, err := auto.debugger.GetTargets()
	if err != nil {
		return err
	}
	auto.tabLock.Lock()
	for _, tab := range tabs {
		t, err := open(tab)
		if err != nil {
			return err
		}
		auto.tabs[tab.Target.Id] = t
	}
	auto.tabLock.Unlock()
	return nil
}
func (auto *AutoGcd) Shutdown() error {
	if auto.shutdown {
		return errors.New("AutoGcd already shut down.")
	}
	auto.tabLock.Lock()
	for _, tab := range auto.tabs {
		tab.close()  
		auto.debugger.CloseTab(tab.ChromeTarget)
	}
	auto.tabLock.Unlock()
	if !auto.settings.connectToInstance {
		err := auto.debugger.ExitProcess()
		if auto.settings.removeUserDir == true {
			return os.RemoveAll(auto.settings.userDir)
		}
		return err
	}
	auto.shutdown = true
	return nil
}
func (auto *AutoGcd) RefreshTabList() (map[string]*Tab, error) {
	knownTabs := auto.GetAllTabs()
	knownIds := make(map[string]struct{}, len(knownTabs))
	for _, v := range knownTabs {
		knownIds[v.Target.Id] = struct{}{}
	}
	newTabs, err := auto.debugger.GetNewTargets(knownIds)
	if err != nil {
		return nil, err
	}
	auto.tabLock.Lock()
	for _, newTab := range newTabs {
		t, err := open(newTab)
		if err != nil {
			return nil, err
		}
		auto.tabs[newTab.Target.Id] = t
	}
	auto.tabLock.Unlock()
	return auto.GetAllTabs(), nil
}