"WebDriver-Chrome" (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

    open allclose all

    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:

    Scope  (5)

    Start a new browser session:

    Open a webpage:

    Get the webpage title:

    Delete the session:

    Start a new browser session:

    Open a webpage:

    Refresh the page:

    Delete the session:

    Start a new browser session:

    Open a webpage:

    Get all the <p> elements:

    Get the text for each element:

    Delete the session:

    Start a new browser session:

    Open a webpage:

    Execute a JavaScript command in the browser session:

    Delete the session:

    Create a form:

    Deploy the form to the cloud:

    Get the URL of the cloud object:

    Start a new browser session:

    Open the form in the browser:

    Enter a number in the input field:

    Click the submit button:

    Delete the session:

    Introduced in 2018
     (11.3)