Control a Web Browser Programmatically
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:
Get a reference to the button on the webpage that initiates a search:
Enter “Ada Lovelace” in the search field, then click the search button:
End the web session
To end the web session, delete the web session object: