Intro: Python, and Robin

Why would you want to use Splinter? From the docs:

“Splinter is an abstraction layer on top of existing browser automation tools such as Selenium and zope.testbrowser. It has a high-level API that makes it easy to write automated tests of web applications.”

But, you might well ask, "Isn’t it a testing application, and not an RPA tool? "

Some of you may have noticed the overlap between “test automation” and RPA. The objectives are clearly different, but to some extent you can perform test automation with RPA tools, and vice versa. For example, you can do RPA tasks with taiko even though it’s not billed as an RPA tool. We can do at least some ad hoc test automation with Robin.

Splinter isn’t billed as an RPA tool either, as you can see from docs. But we can use it for one.

I may be grossly oversimplifying here, but it appears to me that any test automation tool that has an “evaluate” method can also be used (at least to some extent) for RPA. Splinter’s got that:

Here we’ll give Splinter a test run, with some code shamelessly filched and cloned from the docs.




Robin code:

System.GetEnvironmentVariable \
    Name:  'USERNAME' \
    Value=> UserName

set pythonPath to 'C:\Users\\'+UserName+'\AppData\Local\Programs\Python\Python37\python.exe'

set workDir to 'C:\Users\\'+UserName+'\Documents\Robin\9.2\splinter'

set pyScript to workDir +'\ '

System.RunDOSCommand \
    DOSCommandOrApplication: pythonPath + ' ' + pyScript \
    WorkingDirectory: workDir \
    StandardOutput=> StandardOutput \
    StandardError=> StandardError \
    ExitCode=> ExitCode

Console.Write Message: 'stdout: '+ StandardOutput
Console.Write Message: 'stderr (if any): '+ StandardError
Console.Write Message: 'exit code (if any): ' + ExitCode

Contents of ‘’:

from splinter import Browser

with Browser() as browser:
# Visit URL
url = ""
robindocsurl = ""
browser.fill('q', '')
# Find and click the 'search' button
button = browser.find_by_name('btnK')
# Interact with elements
if browser.is_text_present('The RPA Language'):
    print("Yes, the official Robin docs website was found!")
    print("No, it wasn't found... We need to improve our SEO techniques")

Edit: If the Python script above crashes and burns, try this code to find the button:

button = browser.find_by_xpath("//div[@class='FPdoLc tfB0Bf']//input[@name='btnK']")

Or, even better perhaps (since ‘find_by_xpath()’ extracts all elements matching the XPath arg, returning a list of Element objects):

button = browser.find_by_xpath("//div[@class='FPdoLc tfB0Bf']//input[@name='btnK']")[0]

Some other ways to find elements, from the docs:

browser.find_by_text(‘Hello World!’)

Notice we use ‘System.RunDOSCommand’ so we can grab stdout, stderr, and an exit code.