Skip to content

RPA for Python Scripts

The following script uses a number of 'RPA for Python' commands.

The comments in the code should help to clarify what is going on

import rpa as r

# use init() to start TagUI, it auto downloads TagUI on first run
# default init(visual_automation = False, chrome_browser = True)
r.init()
# r.init(turbo_mode = True)
# r.init(headless_mode = True)


# launch browser and go to url
r.url('https://verdapress.uk/services/test-bed/')

# use print to display output on screen
print(r.url())


# get/display page title
print(r.title())

# wait for page to load

r.wait(5)

# Take a snapshot (.png of the web page)
# this file will be saved into the directory from which the script is run

r.snap('page', 'pythonimage.png')


# get table data - always useful and write to csv file
# this data is being pulled from the web page in
# r.url('https://verdapress.uk/services/test-bed/')
# this file will be saved into the directory from which the script is run
r.table(1, 'python_table.csv')


# ask the user for a url and the web page will be displayed
# enter a full url e.g. https://osuch.com

r.url(r.ask('Please enter a url'))

# wait for page to load. could use other function e.g. present()/exist

r.wait(5)

# Take a snapshot (.png of the web page)
# this file will be saved into the directory from which the script is run
r.snap('page', 'pythonedimage2.png')

# wait 2 seconds before closing the script/browser
r.wait(2)

# always close before completing your script 
r.close()

To run this sample, copy and paste the code into a .py file e.g sample.py.

From the command prompt type:

py sample.py

Press Enter.

Your favourite web site along will be displayed along with useful site information in the command prompt.

If familiar with TagUI you should see similarities in the commands being used.