"WebDriver-Chrome-Headless" (External Evaluation System)

This functionality has been replaced by WebExecute.
  • WebDriver is a standard for controlling web browsers programmatically.
    WebDriver is a proposed W3C standard: https://www.w3.org/TR/webdriver.
    Supports Chrome and Firefox web browsers.
  • Details

    • Both Chrome and Firefox are supported in a "headless" mode where the browser window is not displayed, but is still rendered on your computer system.

    ExternalEvaluate Usage

    • ExternalEvaluate["WebDriver-browser",commandargs] executes command with args in browser and returns a Wolfram Language expression if applicable.
    • The following commands are supported for executing in a web session:
    • "OpenWebPage"go to a webpage
      "CaptureWebPage"capture an image of the current webpage
      "RefreshWebPage"refresh the current webpage
      "PageBack"go back to the previous webpage
      "PageForward"go forward to the next webpage
      "WebPageTitle"the title of the webpage
      "JavascriptExecute"execute a bit of JavaScript code in the webpage
      "WindowSize"the current window size
      "SetWindowSize"set the window size
      "LocateElements"locate elements on the page given a locator element
      "ClickElement"click an element
      "HoverElement"hover the mouse over an element
      "HideElement"set an element's visibility property to "hidden"
      "ShowElement"set an element's visibility property to "visible"
      "ElementText"an element's text, if any
      "ElementName"the name of the element
      "ElementSelected"whether the element is selected or not
      "ElementEnabled"whether the element is enabled or not
      "SubmitElement"submit a form element
      "FocusFrame"focus the webpage on an element
      "TypeElement"type text into an element

    Data Types

    • WebDriver supports specifying elements on a webpage in multiple ways, referred to as locator elements.
    • Elements may be returned using the "LocateElements" command.
    • The following locator element specifications are supported:
    • <|"ID"id|>a name of the element ID in HTML
      <|"XPath"xpath|>an XPath selector
      <|"ElementClassName"name|>an element class name in HTML
      <|"CSSSelector"name|>a CSS selector
      <|"Name"name|>an element name
      <|"LinkText"name|>an element containing the link text
      <|"PartialLinkText"name|>an element matching the link text
      <|"TagName"name|>a tag name
    • The "ID" and "TagName" search methods are only supported with "WebDriver-Chrome" and "WebDriver-Chrome-Headless".

    Examples

    Basic Examples  (2)

    Open a webpage and capture an image of it:

    Locate an element on the page and click it:

    Open the webpage and locate the "nav-search" element with its ID:

    Click the element:

    Capture an image of the webpage:

    Delete the session: