How to open Google in a web browser with Python and search using an AppRobotic macro?

How to open Google in a web browser with Python and search using an AppRobotic macro?

QA 0

AppRobotic can be used to create a simple macro to perform any action in a web browser. The code example below leverages Python to open a web browser window, and perform a simple search on Google.

Python Code:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")

# specify URL
url = "https://www.google.com"

# open with Edge browser
x.OpenURLEdge(url)

# wait a bit for page to open
x.Wait(3000)
# use UI Item Explorer to find the X,Y coordinates of Search box
x.MoveCursor(438, 435)
# click inside Search box
x.MouseLeftClick

x.Type("AppRobotic")
x.Type("{ENTER}")

If using the AppRobotic Professional RPA Edition, the ‘Run Application’ command is also available to launch a particular web browser:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
x.RunApplication("firefox.exe")