page method

WebSocketChannel page({
  1. bool? blockAds,
  2. CDPLaunchOptionsOrString? launch,
  3. String? profile,
  4. num? timeout,
  5. String? token,
  6. String? trackingId,
  7. dynamic body,
})

Protocol: WebSocket Connect to an existing page in Chromium with a library like chrome-remote-interface or others that work the page websocketDebugger URL. You can get this unique URL by calling the /json/list API or by finding the page's unique ID from your library of choice. Summary: /devtools/page/*

Implementation

WebSocketChannel page({
  bool? blockAds,
  CDPLaunchOptionsOrString? launch,
  String? profile,
  num? timeout,
  String? token,
  String? trackingId,
  dynamic body,
}) {
  final queryParams = <String, String>{};
  if (defaultToken != null) {
    queryParams['token'] = defaultToken!;
  }
  if (blockAds != null) {
    queryParams['blockAds'] = blockAds.toString();
  }
  if (launch != null) {
    queryParams['launch'] = launch.toString();
  }
  if (profile != null) {
    queryParams['profile'] = profile.toString();
  }
  if (timeout != null) {
    queryParams['timeout'] = timeout.toString();
  }
  if (token != null) {
    queryParams['token'] = token.toString();
  }
  if (trackingId != null) {
    queryParams['trackingId'] = trackingId.toString();
  }
  final pathUrl = '/devtools/page/*';
  final uri = Uri.parse(
    '$baseUrl$pathUrl',
  ).replace(queryParameters: queryParams.isNotEmpty ? queryParams : null);
  final wsUri = uri.replace(scheme: uri.scheme == 'https' ? 'wss' : 'ws');
  return WebSocketChannel.connect(wsUri);
}