Automating Web Page Test with Robot Framework API

  • Share this:

Code introduction


This function uses the Robot Framework API to automate a simple web page test, including opening a browser, setting speed, taking a screenshot, logging, and closing the browser.


Technology Stack : Robot Framework, Selenium WebDriver

Code Type : The type of code

Code Difficulty : Intermediate


                
                    
import random
from robot.api import Robot

def generate_random_report(title, description):
    robot = Robot()
    robot.start_selenium_server()
    robot.open_browser("http://www.example.com")
    robot.set_speed(30)
    robot.get_screenshot("screenshot.png")
    robot.run_keyword("Log", f"Title: {title}, Description: {description}")
    robot.close_browser()
    robot.stop_selenium_server()