createTarget method

Future<TargetID> createTarget(
  1. String url, {
  2. int? left,
  3. int? top,
  4. int? width,
  5. int? height,
  6. WindowState? windowState,
  7. BrowserContextID? browserContextId,
  8. bool? enableBeginFrameControl,
  9. bool? newWindow,
  10. bool? background,
  11. bool? forTab,
  12. bool? hidden,
  13. bool? focus,
})

Creates a new page. url The initial URL the page will be navigated to. An empty string indicates about:blank. left Frame left origin in DIP (requires newWindow to be true or headless shell). top Frame top origin in DIP (requires newWindow to be true or headless shell). width Frame width in DIP (requires newWindow to be true or headless shell). height Frame height in DIP (requires newWindow to be true or headless shell). windowState Frame window state (requires newWindow to be true or headless shell). Default is normal. browserContextId The browser context to create the page in. enableBeginFrameControl Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default). newWindow Whether to create a new Window or Tab (false by default, not supported by headless shell). background Whether to create the target in background or foreground (false by default, not supported by headless shell). forTab Whether to create the target of type "tab". hidden Whether to create a hidden target. The hidden target is observable via protocol, but not present in the tab UI strip. Cannot be created with forTab: true, newWindow: true or background: false. The life-time of the tab is limited to the life-time of the session. focus If specified, determines whether the new target should be focused. By default, the focus behavior depends on the background parameter:

  • If background is false (default) and focus is omitted, the new target is focused and the browser window is brought to the foreground.
  • If background is false and focus is false, the target is opened but the browser window's focus remains unchanged (e.g., if the window was in the background, it stays there).
  • If background is true, setting focus to true is not supported and will result in an error. Returns: The id of the page opened.

Implementation

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