Tungsten v0.1.0 Tungsten.CDP.Page View Source

Page

Actions and events related to the inspected page belong to the page domain.

Link to this section Summary

Functions

Link to this section Types

Link to this type

cdp_app_manifest_error_type() View Source
cdp_app_manifest_error_type() :: %{
  message: String.t(),
  critical: integer(),
  line: integer(),
  column: integer()
}

Page.AppManifestError

Error while paring app manifest.

Link to this type

cdp_client_navigation_reason_type() View Source
cdp_client_navigation_reason_type() ::
  :reload
  | :page_block_interstitial
  | :meta_tag_refresh
  | :script_initiated
  | :http_header_refresh
  | :form_submission_post
  | :form_submission_get

Page.ClientNavigationReason

This type has no documentation

Link to this type

cdp_dialog_type_type() View Source
cdp_dialog_type_type() :: :beforeunload | :prompt | :confirm | :alert

Page.DialogType

Javascript dialog type.

Link to this type

cdp_font_families_type() View Source
cdp_font_families_type() :: %{
  optional(:standard) => String.t(),
  optional(:fixed) => String.t(),
  optional(:serif) => String.t(),
  optional(:sans_serif) => String.t(),
  optional(:cursive) => String.t(),
  optional(:fantasy) => String.t(),
  optional(:pictograph) => String.t()
}

Page.FontFamilies

Generic font families collection.

Link to this type

cdp_font_sizes_type() View Source
cdp_font_sizes_type() :: %{
  optional(:standard) => integer(),
  optional(:fixed) => integer()
}

Page.FontSizes

Default font sizes.

Link to this type

cdp_frame_id_type() View Source
cdp_frame_id_type() :: String.t()

Page.FrameId

Unique frame identifier.

Link to this type

cdp_frame_resource_tree_type() View Source
cdp_frame_resource_tree_type() :: %{
  :frame => cdp_frame_type(),
  optional(:child_frames) => [cdp_frame_resource_tree_type()],
  :resources => [cdp_frame_resource_type()]
}

Page.FrameResourceTree

Information about the Frame hierarchy along with their cached resources.

Link to this type

cdp_frame_resource_type() View Source
cdp_frame_resource_type() :: %{
  :url => String.t(),
  :type => Tungsten.CDP.Network.cdp_resource_type_type(),
  :mime_type => String.t(),
  optional(:last_modified) => Tungsten.CDP.Network.cdp_time_since_epoch_type(),
  optional(:content_size) => integer() | float(),
  optional(:failed) => boolean(),
  optional(:canceled) => boolean()
}

Page.FrameResource

Information about the Resource on the page.

Link to this type

cdp_frame_tree_type() View Source
cdp_frame_tree_type() :: %{
  :frame => cdp_frame_type(),
  optional(:child_frames) => [cdp_frame_tree_type()]
}

Page.FrameTree

Information about the Frame hierarchy.

Link to this type

cdp_frame_type() View Source
cdp_frame_type() :: %{
  :id => String.t(),
  optional(:parent_id) => String.t(),
  :loader_id => Tungsten.CDP.Network.cdp_loader_id_type(),
  optional(:name) => String.t(),
  :url => String.t(),
  :security_origin => String.t(),
  :mime_type => String.t(),
  optional(:unreachable_url) => String.t()
}

Page.Frame

Information about the Frame on the page.

Link to this type

cdp_layout_viewport_type() View Source
cdp_layout_viewport_type() :: %{
  page_x: integer(),
  page_y: integer(),
  client_width: integer(),
  client_height: integer()
}

Page.LayoutViewport

Layout viewport position and dimensions.

Link to this type

cdp_navigation_entry_type() View Source
cdp_navigation_entry_type() :: %{
  id: integer(),
  url: String.t(),
  user_typed_url: String.t(),
  title: String.t(),
  transition_type: cdp_transition_type_type()
}

Page.NavigationEntry

Navigation history entry.

Link to this type

cdp_screencast_frame_metadata_type() View Source
cdp_screencast_frame_metadata_type() :: %{
  :offset_top => integer() | float(),
  :page_scale_factor => integer() | float(),
  :device_width => integer() | float(),
  :device_height => integer() | float(),
  :scroll_offset_x => integer() | float(),
  :scroll_offset_y => integer() | float(),
  optional(:timestamp) => Tungsten.CDP.Network.cdp_time_since_epoch_type()
}

Page.ScreencastFrameMetadata

Screencast frame metadata.

Link to this type

cdp_script_identifier_type() View Source
cdp_script_identifier_type() :: String.t()

Page.ScriptIdentifier

Unique script identifier.

Link to this type

cdp_transition_type_type() View Source
cdp_transition_type_type() ::
  :other
  | :keyword_generated
  | :keyword
  | :reload
  | :form_submit
  | :auto_toplevel
  | :generated
  | :manual_subframe
  | :auto_subframe
  | :auto_bookmark
  | :address_bar
  | :typed
  | :link

Page.TransitionType

Transition type.

Link to this type

cdp_viewport_type() View Source
cdp_viewport_type() :: %{
  x: integer() | float(),
  y: integer() | float(),
  width: integer() | float(),
  height: integer() | float(),
  scale: integer() | float()
}

Page.Viewport

Viewport for capturing screenshot.

Link to this type

cdp_visual_viewport_type() View Source
cdp_visual_viewport_type() :: %{
  :offset_x => integer() | float(),
  :offset_y => integer() | float(),
  :page_x => integer() | float(),
  :page_y => integer() | float(),
  :client_width => integer() | float(),
  :client_height => integer() | float(),
  :scale => integer() | float(),
  optional(:zoom) => integer() | float()
}

Page.VisualViewport

Visual viewport position, dimensions, and scale.

Link to this section Functions

Link to this function

add_compilation_cache(session, parameters, options \\ []) View Source
add_compilation_cache(
  GenServer.server(),
  %{url: String.t(), data: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.addCompilationCache

Seeds compilation cache for given url. Compilation cache does not survive cross-process navigation.

Link to this function

add_script_to_evaluate_on_load(session, parameters, options \\ []) View Source
add_script_to_evaluate_on_load(
  GenServer.server(),
  %{script_source: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{identifier: cdp_script_identifier_type()}} | {:error, term()}

Page.addScriptToEvaluateOnLoad

Deprecated, please use addScriptToEvaluateOnNewDocument instead.

Link to this function

add_script_to_evaluate_on_new_document(session, parameters, options \\ []) View Source
add_script_to_evaluate_on_new_document(
  GenServer.server(),
  %{:source => String.t(), optional(:world_name) => String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{identifier: cdp_script_identifier_type()}} | {:error, term()}

Page.addScriptToEvaluateOnNewDocument

Evaluates given script in every frame upon creation (before loading frame's scripts).

Link to this function

bring_to_front(session, parameters \\ %{}, options \\ []) View Source
bring_to_front(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.bringToFront

Brings page to front (activates tab).

Link to this function

capture_screenshot(session, parameters \\ %{}, options \\ []) View Source
capture_screenshot(
  GenServer.server(),
  %{
    optional(:format) => :png | :jpeg,
    optional(:quality) => integer(),
    optional(:clip) => cdp_viewport_type(),
    optional(:from_surface) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{data: String.t()}} | {:error, term()}

Page.captureScreenshot

Capture page screenshot.

Link to this function

capture_snapshot(session, parameters \\ %{}, options \\ []) View Source
capture_snapshot(
  GenServer.server(),
  %{optional(:format) => :mhtml},
  Tungsten.Connection.exec_options()
) :: {:ok, %{data: String.t()}} | {:error, term()}

Page.captureSnapshot

Returns a snapshot of the page as a string. For MHTML format, the serialization includes iframes, shadow DOM, external resources, and element-inline styles.

Link to this function

clear_compilation_cache(session, parameters \\ %{}, options \\ []) View Source
clear_compilation_cache(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.clearCompilationCache

Clears seeded compilation cache.

Link to this function

clear_device_metrics_override(session, parameters \\ %{}, options \\ []) View Source
clear_device_metrics_override(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.clearDeviceMetricsOverride

Clears the overriden device metrics.

Link to this function

clear_device_orientation_override(session, parameters \\ %{}, options \\ []) View Source
clear_device_orientation_override(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.clearDeviceOrientationOverride

Clears the overridden Device Orientation.

Link to this function

clear_geolocation_override(session, parameters \\ %{}, options \\ []) View Source
clear_geolocation_override(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.clearGeolocationOverride

Clears the overriden Geolocation Position and Error.

Link to this function

close(session, parameters \\ %{}, options \\ []) View Source
close(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.close

Tries to close page, running its beforeunload hooks, if any.

Link to this function

crash(session, parameters \\ %{}, options \\ []) View Source
crash(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.crash

Crashes renderer on the IO thread, generates minidumps.

Link to this function

create_isolated_world(session, parameters, options \\ []) View Source
create_isolated_world(
  GenServer.server(),
  %{
    :frame_id => cdp_frame_id_type(),
    optional(:world_name) => String.t(),
    optional(:grant_univeral_access) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{execution_context_id: Tungsten.CDP.Runtime.cdp_execution_context_id_type()}}
  | {:error, term()}

Page.createIsolatedWorld

Creates an isolated world for the given frame.

Link to this function

delete_cookie(session, parameters, options \\ []) View Source
delete_cookie(
  GenServer.server(),
  %{cookie_name: String.t(), url: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.deleteCookie

Deletes browser cookie with given name, domain and path.

Link to this function

disable(session, parameters \\ %{}, options \\ []) View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.disable

Disables page domain notifications.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.enable

Enables page domain notifications.

Link to this function

generate_test_report(session, parameters, options \\ []) View Source
generate_test_report(
  GenServer.server(),
  %{:message => String.t(), optional(:group) => String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.generateTestReport

Generates a report for testing.

Link to this function

get_app_manifest(session, parameters \\ %{}, options \\ []) View Source
get_app_manifest(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok,
   %{
     :url => String.t(),
     :errors => [cdp_app_manifest_error_type()],
     optional(:data) => String.t()
   }}
  | {:error, term()}

Page.getAppManifest

This command has no documentation

Link to this function

get_cookies(session, parameters \\ %{}, options \\ []) View Source
get_cookies(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, %{cookies: [Tungsten.CDP.Network.cdp_cookie_type()]}} | {:error, term()}

Page.getCookies

Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.

Link to this function

get_frame_tree(session, parameters \\ %{}, options \\ []) View Source
get_frame_tree(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, %{frame_tree: cdp_frame_tree_type()}} | {:error, term()}

Page.getFrameTree

Returns present frame tree structure.

Link to this function

get_layout_metrics(session, parameters \\ %{}, options \\ []) View Source
get_layout_metrics(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     layout_viewport: cdp_layout_viewport_type(),
     visual_viewport: cdp_visual_viewport_type(),
     content_size: Tungsten.CDP.DOM.cdp_rect_type()
   }}
  | {:error, term()}

Page.getLayoutMetrics

Returns metrics relating to the layouting of the page, such as viewport bounds/scale.

Link to this function

get_navigation_history(session, parameters \\ %{}, options \\ []) View Source
get_navigation_history(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{current_index: integer(), entries: [cdp_navigation_entry_type()]}}
  | {:error, term()}

Page.getNavigationHistory

Returns navigation history for the current page.

Link to this function

get_resource_content(session, parameters, options \\ []) View Source
get_resource_content(
  GenServer.server(),
  %{frame_id: cdp_frame_id_type(), url: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{content: String.t(), base64_encoded: boolean()}} | {:error, term()}

Page.getResourceContent

Returns content of the given resource.

Link to this function

get_resource_tree(session, parameters \\ %{}, options \\ []) View Source
get_resource_tree(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{frame_tree: cdp_frame_resource_tree_type()}} | {:error, term()}

Page.getResourceTree

Returns present frame / resource tree structure.

Link to this function

handle_java_script_dialog(session, parameters, options \\ []) View Source
handle_java_script_dialog(
  GenServer.server(),
  %{:accept => boolean(), optional(:prompt_text) => String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.handleJavaScriptDialog

Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).

Link to this function

reload(session, parameters \\ %{}, options \\ []) View Source
reload(
  GenServer.server(),
  %{
    optional(:ignore_cache) => boolean(),
    optional(:script_to_evaluate_on_load) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.reload

Reloads given page optionally ignoring the cache.

Link to this function

remove_script_to_evaluate_on_load(session, parameters, options \\ []) View Source
remove_script_to_evaluate_on_load(
  GenServer.server(),
  %{identifier: cdp_script_identifier_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.removeScriptToEvaluateOnLoad

Deprecated, please use removeScriptToEvaluateOnNewDocument instead.

Link to this function

remove_script_to_evaluate_on_new_document(session, parameters, options \\ []) View Source
remove_script_to_evaluate_on_new_document(
  GenServer.server(),
  %{identifier: cdp_script_identifier_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.removeScriptToEvaluateOnNewDocument

Removes given script from the list.

Link to this function

reset_navigation_history(session, parameters \\ %{}, options \\ []) View Source
reset_navigation_history(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.resetNavigationHistory

Resets navigation history for the current page.

Link to this function

screencast_frame_ack(session, parameters, options \\ []) View Source
screencast_frame_ack(
  GenServer.server(),
  %{session_id: integer()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.screencastFrameAck

Acknowledges that a screencast frame has been received by the frontend.

Link to this function

search_in_resource(session, parameters, options \\ []) View Source
search_in_resource(
  GenServer.server(),
  %{
    :frame_id => cdp_frame_id_type(),
    :url => String.t(),
    :query => String.t(),
    optional(:case_sensitive) => boolean(),
    optional(:is_regex) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{result: [Tungsten.CDP.Debugger.cdp_search_match_type()]}}
  | {:error, term()}

Page.searchInResource

Searches for given string in resource content.

Link to this function

set_ad_blocking_enabled(session, parameters, options \\ []) View Source
set_ad_blocking_enabled(
  GenServer.server(),
  %{enabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setAdBlockingEnabled

Enable Chrome's experimental ad filter on all sites.

Link to this function

set_bypass_csp(session, parameters, options \\ []) View Source
set_bypass_csp(
  GenServer.server(),
  %{enabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setBypassCSP

Enable page Content Security Policy by-passing.

Link to this function

set_device_metrics_override(session, parameters, options \\ []) View Source
set_device_metrics_override(
  GenServer.server(),
  %{
    :width => integer(),
    :height => integer(),
    :device_scale_factor => integer() | float(),
    :mobile => boolean(),
    optional(:scale) => integer() | float(),
    optional(:screen_width) => integer(),
    optional(:screen_height) => integer(),
    optional(:position_x) => integer(),
    optional(:position_y) => integer(),
    optional(:dont_set_visible_size) => boolean(),
    optional(:screen_orientation) =>
      Tungsten.CDP.Emulation.cdp_screen_orientation_type(),
    optional(:viewport) => cdp_viewport_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setDeviceMetricsOverride

Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).

Link to this function

set_device_orientation_override(session, parameters, options \\ []) View Source
set_device_orientation_override(
  GenServer.server(),
  %{
    alpha: integer() | float(),
    beta: integer() | float(),
    gamma: integer() | float()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setDeviceOrientationOverride

Overrides the Device Orientation.

Link to this function

set_document_content(session, parameters, options \\ []) View Source
set_document_content(
  GenServer.server(),
  %{frame_id: cdp_frame_id_type(), html: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setDocumentContent

Sets given markup as the document's HTML.

Link to this function

set_download_behavior(session, parameters, options \\ []) View Source
set_download_behavior(
  GenServer.server(),
  %{
    :behavior => :default | :allow | :deny,
    optional(:download_path) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setDownloadBehavior

Set the behavior when downloading a file.

Link to this function

set_font_families(session, parameters, options \\ []) View Source
set_font_families(
  GenServer.server(),
  %{font_families: cdp_font_families_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setFontFamilies

Set generic font families.

Link to this function

set_font_sizes(session, parameters, options \\ []) View Source
set_font_sizes(
  GenServer.server(),
  %{font_sizes: cdp_font_sizes_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setFontSizes

Set default font sizes.

Link to this function

set_geolocation_override(session, parameters \\ %{}, options \\ []) View Source
set_geolocation_override(
  GenServer.server(),
  %{
    optional(:latitude) => integer() | float(),
    optional(:longitude) => integer() | float(),
    optional(:accuracy) => integer() | float()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setGeolocationOverride

Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.

Link to this function

set_lifecycle_events_enabled(session, parameters, options \\ []) View Source
set_lifecycle_events_enabled(
  GenServer.server(),
  %{enabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setLifecycleEventsEnabled

Controls whether page will emit lifecycle events.

Link to this function

set_produce_compilation_cache(session, parameters, options \\ []) View Source
set_produce_compilation_cache(
  GenServer.server(),
  %{enabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setProduceCompilationCache

Forces compilation cache to be generated for every subresource script.

Link to this function

set_touch_emulation_enabled(session, parameters, options \\ []) View Source
set_touch_emulation_enabled(
  GenServer.server(),
  %{:enabled => boolean(), optional(:configuration) => :desktop | :mobile},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setTouchEmulationEnabled

Toggles mouse event-based touch event emulation.

Link to this function

set_web_lifecycle_state(session, parameters, options \\ []) View Source
set_web_lifecycle_state(
  GenServer.server(),
  %{state: :active | :frozen},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.setWebLifecycleState

Tries to update the web lifecycle state of the page. It will transition the page to the given state according to: https://github.com/WICG/web-lifecycle/

Link to this function

start_screencast(session, parameters \\ %{}, options \\ []) View Source
start_screencast(
  GenServer.server(),
  %{
    optional(:format) => :png | :jpeg,
    optional(:quality) => integer(),
    optional(:max_width) => integer(),
    optional(:max_height) => integer(),
    optional(:every_nth_frame) => integer()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.startScreencast

Starts sending each frame using the screencastFrame event.

Link to this function

stop_loading(session, parameters \\ %{}, options \\ []) View Source
stop_loading(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.stopLoading

Force the page stop all navigations and pending resource fetches.

Link to this function

stop_screencast(session, parameters \\ %{}, options \\ []) View Source
stop_screencast(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Page.stopScreencast

Stops sending each frame in the screencastFrame.

Link to this function

wait_for_debugger(session, parameters \\ %{}, options \\ []) View Source
wait_for_debugger(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Page.waitForDebugger

Pauses page execution. Can be resumed using generic Runtime.runIfWaitingForDebugger.