Open and query webpages, manipulate DOM elements and run JavaScript code in a browser.

Start a web session

Use StartWebSession to open a new, empty browser window:

  • Supported browsers are Chrome and Firefox. If no arguments are given to StartWebSession, it defaults to Chrome.
  • Several web sessions can run simultaneously.

Open a webpage

Open a webpage in the browser:

  • Opening a webpage yields a Success object even when the URL is not a valid destination.
  • Web session commands include "PageBack", "ClickElement", "TypeElement", "BrowserWindows" and "SetWindowSize". See the WebExecute documentation for a complete list.

Extract information about the page

Get the webpage title:

Get the webpage URL:

Get a list of hyperlinks on the webpage:

Manipulate the document object model (DOM)

Use the "LocateElements" option to search for elements in the DOM.

Get a reference to the search field on the webpage:

In[6]:=
Click for copyable input
Out[6]=

Get a reference to the button on the webpage that initiates a search:

In[7]:=
Click for copyable input
Out[7]=

Enter Ada Lovelace in the search field, then click the search button:

Execute JavaScript code on the page

Pass a block of JavaScript code as a string to WebExecute, and the web driver will execute that code on the live page:

End the web session

To end the web session, delete the web session object:

In[10]:=
Click for copyable input