func (c *Target) CreateTarget(ctx context.Context, url string, width int, height int, browserContextId string, enableBeginFrameControl bool, newWindow bool, background bool) (string, error) {
	var v TargetCreateTargetParams
	v.Url = url
	v.Width = width
	v.Height = height
	v.BrowserContextId = browserContextId
	v.EnableBeginFrameControl = enableBeginFrameControl
	v.NewWindow = newWindow
	v.Background = background
	return c.CreateTargetWithParams(ctx, &v)
}
CreateTarget - Creates a new page.
url - The initial URL the page will be navigated to. An empty string indicates about:blank.
width - Frame width in DIP (headless chrome only).
height - Frame height in DIP (headless chrome only).
browserContextId - The browser context to create the page in.
enableBeginFrameControl - Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).
newWindow - Whether to create a new Window or Tab (chrome-only, false by default).
background - Whether to create the target in background or foreground (chrome-only, false by default).
Returns -  targetId - The id of the page opened.
package gcdapi
import (
	"context"
	"github.com/wirepair/gcd/v2/gcdmessage"
)
type TargetTargetInfo struct {
	TargetId         string `json:"targetId"`                    
	Type             string `json:"type"`                        
	Title            string `json:"title"`                       
	Url              string `json:"url"`                         
	Attached         bool   `json:"attached"`                    
	OpenerId         string `json:"openerId,omitempty"`          
	CanAccessOpener  bool   `json:"canAccessOpener"`             
	OpenerFrameId    string `json:"openerFrameId,omitempty"`     
	BrowserContextId string `json:"browserContextId,omitempty"`  
}
type TargetRemoteLocation struct {
	Host string `json:"host"`  
	Port int    `json:"port"`  
}
type TargetAttachedToTargetEvent struct {
	Method string `json:"method"`
	Params struct {
		SessionId          string            `json:"sessionId"`           
		TargetInfo         *TargetTargetInfo `json:"targetInfo"`          
		WaitingForDebugger bool              `json:"waitingForDebugger"`  
	} `json:"Params,omitempty"`
}
type TargetDetachedFromTargetEvent struct {
	Method string `json:"method"`
	Params struct {
		SessionId string `json:"sessionId"`           
		TargetId  string `json:"targetId,omitempty"`  
	} `json:"Params,omitempty"`
}
type TargetReceivedMessageFromTargetEvent struct {
	Method string `json:"method"`
	Params struct {
		SessionId string `json:"sessionId"`           
		Message   string `json:"message"`             
		TargetId  string `json:"targetId,omitempty"`  
	} `json:"Params,omitempty"`
}
type TargetTargetCreatedEvent struct {
	Method string `json:"method"`
	Params struct {
		TargetInfo *TargetTargetInfo `json:"targetInfo"`  
	} `json:"Params,omitempty"`
}
type TargetTargetDestroyedEvent struct {
	Method string `json:"method"`
	Params struct {
		TargetId string `json:"targetId"`  
	} `json:"Params,omitempty"`
}
type TargetTargetCrashedEvent struct {
	Method string `json:"method"`
	Params struct {
		TargetId  string `json:"targetId"`   
		Status    string `json:"status"`     
		ErrorCode int    `json:"errorCode"`  
	} `json:"Params,omitempty"`
}
type TargetTargetInfoChangedEvent struct {
	Method string `json:"method"`
	Params struct {
		TargetInfo *TargetTargetInfo `json:"targetInfo"`  
	} `json:"Params,omitempty"`
}
type Target struct {
	target gcdmessage.ChromeTargeter
}
func NewTarget(target gcdmessage.ChromeTargeter) *Target {
	c := &Target{target: target}
	return c
}
type TargetActivateTargetParams struct {
	TargetId string `json:"targetId"`
}
func (c *Target) ActivateTargetWithParams(ctx context.Context, v *TargetActivateTargetParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.activateTarget", Params: v})
}
func (c *Target) ActivateTarget(ctx context.Context, targetId string) (*gcdmessage.ChromeResponse, error) {
	var v TargetActivateTargetParams
	v.TargetId = targetId
	return c.ActivateTargetWithParams(ctx, &v)
}
type TargetAttachToTargetParams struct {
	TargetId string `json:"targetId"`
	Flatten bool `json:"flatten,omitempty"`
}
func (c *Target) AttachToTargetWithParams(ctx context.Context, v *TargetAttachToTargetParams) (string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.attachToTarget", Params: v})
	if err != nil {
		return "", err
	}
	var chromeData struct {
		Result struct {
			SessionId string
		}
	}
	if resp == nil {
		return "", &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", err
	}
	return chromeData.Result.SessionId, nil
}
func (c *Target) AttachToTarget(ctx context.Context, targetId string, flatten bool) (string, error) {
	var v TargetAttachToTargetParams
	v.TargetId = targetId
	v.Flatten = flatten
	return c.AttachToTargetWithParams(ctx, &v)
}
func (c *Target) AttachToBrowserTarget(ctx context.Context) (string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.attachToBrowserTarget"})
	if err != nil {
		return "", err
	}
	var chromeData struct {
		Result struct {
			SessionId string
		}
	}
	if resp == nil {
		return "", &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", err
	}
	return chromeData.Result.SessionId, nil
}
type TargetCloseTargetParams struct {
	TargetId string `json:"targetId"`
}
func (c *Target) CloseTargetWithParams(ctx context.Context, v *TargetCloseTargetParams) (bool, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.closeTarget", Params: v})
	if err != nil {
		return false, err
	}
	var chromeData struct {
		Result struct {
			Success bool
		}
	}
	if resp == nil {
		return false, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return false, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return false, err
	}
	return chromeData.Result.Success, nil
}
func (c *Target) CloseTarget(ctx context.Context, targetId string) (bool, error) {
	var v TargetCloseTargetParams
	v.TargetId = targetId
	return c.CloseTargetWithParams(ctx, &v)
}
type TargetExposeDevToolsProtocolParams struct {
	TargetId string `json:"targetId"`
	BindingName string `json:"bindingName,omitempty"`
}
func (c *Target) ExposeDevToolsProtocolWithParams(ctx context.Context, v *TargetExposeDevToolsProtocolParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.exposeDevToolsProtocol", Params: v})
}
func (c *Target) ExposeDevToolsProtocol(ctx context.Context, targetId string, bindingName string) (*gcdmessage.ChromeResponse, error) {
	var v TargetExposeDevToolsProtocolParams
	v.TargetId = targetId
	v.BindingName = bindingName
	return c.ExposeDevToolsProtocolWithParams(ctx, &v)
}
type TargetCreateBrowserContextParams struct {
	DisposeOnDetach bool `json:"disposeOnDetach,omitempty"`
	ProxyServer string `json:"proxyServer,omitempty"`
	ProxyBypassList string `json:"proxyBypassList,omitempty"`
}
func (c *Target) CreateBrowserContextWithParams(ctx context.Context, v *TargetCreateBrowserContextParams) (string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.createBrowserContext", Params: v})
	if err != nil {
		return "", err
	}
	var chromeData struct {
		Result struct {
			BrowserContextId string
		}
	}
	if resp == nil {
		return "", &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", err
	}
	return chromeData.Result.BrowserContextId, nil
}
func (c *Target) CreateBrowserContext(ctx context.Context, disposeOnDetach bool, proxyServer string, proxyBypassList string) (string, error) {
	var v TargetCreateBrowserContextParams
	v.DisposeOnDetach = disposeOnDetach
	v.ProxyServer = proxyServer
	v.ProxyBypassList = proxyBypassList
	return c.CreateBrowserContextWithParams(ctx, &v)
}
func (c *Target) GetBrowserContexts(ctx context.Context) ([]string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.getBrowserContexts"})
	if err != nil {
		return nil, err
	}
	var chromeData struct {
		Result struct {
			BrowserContextIds []string
		}
	}
	if resp == nil {
		return nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return nil, err
	}
	return chromeData.Result.BrowserContextIds, nil
}
type TargetCreateTargetParams struct {
	Url string `json:"url"`
	Width int `json:"width,omitempty"`
	Height int `json:"height,omitempty"`
	BrowserContextId string `json:"browserContextId,omitempty"`
	EnableBeginFrameControl bool `json:"enableBeginFrameControl,omitempty"`
	NewWindow bool `json:"newWindow,omitempty"`
	Background bool `json:"background,omitempty"`
}
func (c *Target) CreateTargetWithParams(ctx context.Context, v *TargetCreateTargetParams) (string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Target.createTarget", Params: v})
	if err != nil {
		return "", err
	}
	var chromeData struct {
		Result struct {
			TargetId string
		}
	}
	if resp == nil {
		return "", &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", err
	}
	return chromeData.Result.TargetId, nil
}