RPA using robotframework in springboot

ghz 9months ago ⋅ 84 views

I have worked on java spring-boot but I don't have much knowledge about python so I was trying to have some worked around to make robotframework code trigger from springboot application and control robotframework code from springboot . My robotframework code has to do some simple task like opening a website and doing some clicks and other thing for that it uses python SeleniumLibrary.So it would be a great help if I can get the start of how to use robotframework code from springboot and how will robotframework use selenium library if I dont have python on my system and other python library installed.As I dont know if it is a good thing to install java and python library on the system.Plus if I use python then I will also have to start the python env first as I have learned while working in python project you should always create different python env and then install library so that they don't clash with system python library.Is it even possible to work with robot framework for RPA using springboot??

*** Settings *** Library SeleniumLibrary run_on_failure=NOTHING Library BuiltIn Library Collections Test Timeout 10 minutes

*** Test Cases *** Login Test Set Robot Variables From Properties ${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver Call Method ${chrome_options} add_argument --no-sandbox

Call Method ${chrome_options} add_argument --headless

Call Method    ${chrome_options}    add_argument    --start-maximized
Set Selenium Timeout    10sec
Open Browser   https://www.google.com/

I have triggered the above code from python flask but I want to try it with java springboot.And how to do security testing or vulnerability testing of RPA??

Answers

To trigger Robot Framework code from a Spring Boot application and control it, you can use the ProcessBuilder class in Java to execute a Python script that runs your Robot Framework test. This Python script can then import and execute your Robot Framework test suite.

Here's a basic example of how you can achieve this:

  1. Create a Python script that imports and runs your Robot Framework test suite. Make sure you have the necessary SeleniumLibrary and other dependencies installed within the Python environment.
# robot_runner.py

import subprocess

def run_robot_test_suite():
    result = subprocess.run(['robot', 'path/to/your/test_suite.robot'], capture_output=True)
    print(result.stdout.decode())
    print(result.stderr.decode())

if __name__ == '__main__':
    run_robot_test_suite()
  1. In your Spring Boot application, use ProcessBuilder to execute the Python script.
import java.io.IOException;

public class RobotRunner {

    public static void runRobotTestSuite() throws IOException {
        ProcessBuilder processBuilder = new ProcessBuilder("python", "path/to/robot_runner.py");
        Process process = processBuilder.start();

        // Optional: You can read the output of the process if needed
        // BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        // String line;
        // while ((line = reader.readLine()) != null) {
        //     System.out.println(line);
        // }
    }

    public static void main(String[] args) throws IOException {
        runRobotTestSuite();
    }
}
  1. Trigger runRobotTestSuite() method from your Spring Boot application where you want to execute the Robot Framework test suite.

This approach allows you to trigger Robot Framework tests from your Spring Boot application without the need to have Python or Robot Framework installed directly on your system. However, you need to ensure that the Python script and dependencies are properly configured and accessible from your Spring Boot application.

As for security testing or vulnerability testing of RPA, you can integrate security testing tools or vulnerability scanning tools into your Robot Framework test suites. For example, you can use Robot Framework libraries like SecurityTestLibrary or ZAPLibrary for security testing, or integrate other security testing tools into your test suite execution flow. Additionally, you can incorporate security testing best practices into your RPA development process to ensure that your automation scripts are secure and robust.