Making the log.html more verbose when using the API

Viewed 163

I am attempting to use the API for building and running test suites and I've noticed that the log.html that is output when using the API vs the shell is subtly different.

The log when using the command line invocation

The log when using the command line invocation

The log when run through a minimal python script

The log when run through a minimal python script

The minimal python script:

import robot.api
import robot.result
from robot.conf.settings import RobotSettings

options = {
    "output": "./results.xml",
    "log": "./log.html",
    "report": "./report.html",
    "loglevel": "TRACE"
}

settings = RobotSettings(options)

suite = robot.api.TestSuiteBuilder().build(".")
result = suite.run(settings=settings)

result_writer = robot.api.ResultWriter(result)
result_writer.write_results(settings=settings.get_rebot_settings())

As can be seen the log is missing a lot of keyword detail, how can I get this back?

edit: The minimal file after changing it to the correct method:

import robot.api
import robot.result
from robot.conf.settings import RobotSettings

options = {
    "output": "./results.xml",
    "log": "./log.html",
    "report": "./report.html",
    "loglevel": "TRACE",
    "rpa": False
}

settings = RobotSettings(options)

suite = robot.api.TestSuiteBuilder().build(".")
result = suite.run(settings=settings)

result_writer = robot.api.ResultWriter("./results.xml")
result_writer.write_results(settings=settings.get_rebot_settings())
1 Answers

Are you sure you don't have two different Robot Framework packages active on your system? One externally in your path and another as a package within your venv. Try

robot --version

and check if the version in your cmd line is the same as the one running the script. You should also try to upgrade to the latest version, which typically solves such errors.

I have also found a similar error on this thread, which states

The problem is that the result object you get from suite.run(settings) doesn't contain all information about test execution. The reason for this behavior is saving memory during test execution. All information about the execution is in the generated output.xml file, and what you need to do is passing a path to it to the ResultWriter class instead of the result object. This ought to be documented somewhere in the API docs but I'm not sure about it.

Related