Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

Simple robot

Get the code and run this example in your favorite editor on our Portal!

This simple Robot Framework robot opens a web page, stores some text content, and takes a screenshot of an image element on the web page.

The robot written in Robot Framework

This version of the robot (tasks.robot) uses Robot Framework syntax:

*** Settings *** Documentation A simple web scraper robot. ... Opens a website. ... Stores the web page text in a file in the output directory. ... Saves a screenshot of an element in the output directory. Library RPA.Browser.Selenium Library RPA.FileSystem *** Tasks *** Store Web Page Content Open Available Browser https://robotframework.org/ ${text}= Get Text css:body Create File ${OUTPUT_DIR}${/}text.txt ${text} overwrite=True Screenshot css:h1 ${OUTPUT_DIR}${/}screenshot.png [Teardown] Close Browser

The robot written in Python

For comparison, this is the same robot written in Python (tasks.py):

from RPA.Browser.Selenium import Selenium from RPA.FileSystem import FileSystem browser = Selenium() def store_web_page_content(): browser.open_available_browser("https://robotframework.org/") text = browser.get_text("css:body") FileSystem().create_file("output/text.txt", text, overwrite=True) browser.screenshot("css:h1", "output/screenshot.png") def main(): try: store_web_page_content() finally: browser.close_browser() if __name__ == "__main__": main()
Last edit: May 5, 2022