createTarget method

Future<TargetID> createTarget(
  1. String url, {
  2. int? width,
  3. int? height,
  4. BrowserContextID? browserContextId,
  5. bool? enableBeginFrameControl,
  6. bool? newWindow,
  7. bool? background,
  8. bool? forTab,
})

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). forTab Whether to create the target of type "tab". Returns: The id of the page opened.

Implementation

Future<TargetID> createTarget(String url,
    {int? width,
    int? height,
    browser.BrowserContextID? browserContextId,
    bool? enableBeginFrameControl,
    bool? newWindow,
    bool? background,
    bool? forTab}) async {
  var result = await _client.send('Target.createTarget', {
    'url': url,
    if (width != null) 'width': width,
    if (height != null) 'height': height,
    if (browserContextId != null) 'browserContextId': browserContextId,
    if (enableBeginFrameControl != null)
      'enableBeginFrameControl': enableBeginFrameControl,
    if (newWindow != null) 'newWindow': newWindow,
    if (background != null) 'background': background,
    if (forTab != null) 'forTab': forTab,
  });
  return TargetID.fromJson(result['targetId'] as String);
}