How to use rebot method in Robotframework

Best Python code snippet using robotframework

What is Rebot in Robot Framework?

XML output files generated during the execution of tests can be post-processed using Rebot, a tool that is an integral part of Robot Framework. It is automatically used when test reports and logs are generated during the test execution, and using it separately allows creating custom reports and logs as well as combining and merging results.

How to run rebot?

You can use the command line to execute Rebot. Alternatively, you can use the Python interpreter to run the robot/rebot.py file or the installed robot module.

copy
1rebot [options] outputs 2python -m robot.rebot [options] outputs 3python path/to/robot/rebot.py [options] outputs

Code Snippets

Here are code snippets that can help you understand more how developers are using

rebot.py

Source:rebot.py Github

copy

Full Screen

...335 arguments like ``name="Example"`` and generally has a richer API for336 programmatic Rebot execution.337 """338 return Rebot().execute_cli(arguments, exit=exit)339def rebot(*outputs, **options):340 """Programmatic entry point for post-processing outputs.341 :param outputs: Paths to Robot Framework output files similarly342 as when running the ``rebot`` command on the command line.343 :param options: Options to configure processing outputs. Accepted344 options are mostly same as normal command line options to the ``rebot``345 command. Option names match command line option long names without346 hyphens so that, for example, ``--name`` becomes ``name``.347 The semantics related to passing options are exactly the same as with the348 :func:`~robot.run.run` function. See its documentation for more details.349 Examples::350 from robot import rebot351 rebot('path/to/output.xml')352 with open('stdout.txt', 'w') as stdout:353 rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)354 Equivalent command line usage::355 rebot path/to/output.xml356 rebot --name Example --log NONE o1.xml o2.xml > stdout.txt357 """358 return Rebot().execute(*outputs, **options)359if __name__ == '__main__':...

Full Screen

Full Screen

run_tests.py

Source:run_tests.py Github

copy

Full Screen

1#!/usr/bin/env python2import env3import os4import sys5from subprocess import Popen, call6from tempfile import TemporaryFile7from run_unit_tests import run_unit_tests8ROBOT_ARGS = [9 '--doc', 'SeleniumSPacceptanceSPtestsSPwithSP%(browser)s',10 '--outputdir', '%(outdir)s',11 '--variable', 'browser:%(browser)s',12 '--variable', 'pyversion:%(pyVersion)s',13 '--escape', 'space:SP',14 '--report', 'none',15 '--log', 'none',16 #'--suite', 'Acceptance.Keywords.Textfields',17 '--loglevel', 'DEBUG',18 '--pythonpath', '%(pythonpath)s',19 '--noncritical', 'known_issue_-_%(pyVersion)s',20 '--noncritical', 'known_issue_-_%(browser)s',21]22REBOT_ARGS = [23 '--outputdir', '%(outdir)s',24 '--name', '%(browser)sSPAcceptanceSPTests',25 '--escape', 'space:SP',26 '--critical', 'regression',27 '--noncritical', 'inprogress',28 '--noncritical', 'known_issue_-_%(pyVersion)s',29 '--noncritical', 'known_issue_-_%(browser)s',30]31ARG_VALUES = {'outdir': env.RESULTS_DIR, 'pythonpath': ':'.join((env.SRC_DIR, env.TEST_LIBS_DIR))}32def acceptance_tests(interpreter, browser, args):33 ARG_VALUES['browser'] = browser.replace('*', '')34 ARG_VALUES['pyVersion'] = interpreter + sys.version[:3]35 start_http_server()36 runner = {'python': 'pybot', 'jython': 'jybot', 'ipy': 'ipybot'}[interpreter]37 if os.sep == '\\':38 runner += '.bat'39 execute_tests(runner, args)40 stop_http_server()41 return process_output(args)42def start_http_server():43 server_output = TemporaryFile()44 Popen(['python', env.HTTP_SERVER_FILE ,'start'],45 stdout=server_output, stderr=server_output)46def execute_tests(runner, args):47 if not os.path.exists(env.RESULTS_DIR):48 os.mkdir(env.RESULTS_DIR)49 command = [runner] + [arg % ARG_VALUES for arg in ROBOT_ARGS] + args + [env.ACCEPTANCE_TEST_DIR]50 print ''51 print 'Starting test execution with command:\n' + ' '.join(command)52 syslog = os.path.join(env.RESULTS_DIR, 'syslog.txt')53 call(command, shell=os.sep=='\\', env=dict(os.environ, ROBOT_SYSLOG_FILE=syslog))54def stop_http_server():55 call(['python', env.HTTP_SERVER_FILE, 'stop'])56def process_output(args):57 print58 if _has_robot_27():59 call(['python', os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),60 os.path.join(env.RESULTS_DIR, 'output.xml')])61 rebot = 'rebot' if os.sep == '/' else 'rebot.bat'62 rebot_cmd = [rebot] + [ arg % ARG_VALUES for arg in REBOT_ARGS ] + args + \63 [os.path.join(ARG_VALUES['outdir'], 'output.xml') ]64 print ''65 print 'Starting output processing with command:\n' + ' '.join(rebot_cmd)66 rc = call(rebot_cmd, env=os.environ)67 if rc == 0:68 print 'All critical tests passed'69 else:70 print '%d critical test%s failed' % (rc, 's' if rc != 1 else '')71 return rc72def _has_robot_27():73 try:74 from robot.result import ExecutionResult75 except:76 return False77 return True78def _exit(rc):79 sys.exit(rc)80def _help():81 print 'Usage: python run_tests.py python|jython browser [options]'82 print83 print 'See README.txt for details.'84 return 25585def _run_unit_tests():86 print 'Running unit tests'87 failures = run_unit_tests()88 if failures != 0:89 print '\n%d unit tests failed - not running acceptance tests!' % failures90 else:91 print 'All unit tests passed'92 return failures93if __name__ == '__main__':94 if not len(sys.argv) > 2:95 _exit(_help())96 unit_failures = _run_unit_tests()97 if unit_failures:98 _exit(unit_failures)99 interpreter = sys.argv[1]100 browser = sys.argv[2].lower()101 args = sys.argv[3:]102 if browser != 'unit':...

Full Screen

Full Screen

run_acceptance_test.py

Source:run_acceptance_test.py Github

copy

Full Screen

1import env2import os3import sys4from subprocess import call5import start_mongod6"""7Credits for Selenium2Library project for creating the original version8"""9ROBOT_ARGS = [10 '--outputdir', '%(outdir)s',11 '--escape', 'space:SP',12 '--report', 'none',13 '--log', 'none',14 #'--suite', 'Acceptance.Keywords.Textfields',15 '--loglevel', 'DEBUG',16 '--pythonpath', '%(pythonpath)s',17]18REBOT_ARGS = [19 '--outputdir', '%(outdir)s',20 '--name', 'AcceptanceSPTests',21 '--escape', 'space:SP',22 '--critical', 'regression',23 '--noncritical', 'inprogress',24]25ARG_VALUES = {'outdir': env.RESULTS_DIR, 'pythonpath': env.SRC_DIR}26mongo_db_name1 = 'test'27mongo_db_name2 = 'admin'28mongo_db_collection = 'test2013'29mongo_db_document = {"firstName": "John", "lastName": "Smith", "age": 25}30def acceptance_tests(interpreter, args):31 runner = {'python': 'pybot', 'jython': 'jybot', 'ipy': 'ipybot'}[interpreter]32 mongo_db = start_mongod.MongoTemporaryInstance()33 mongo_db.start_mongodb()34 mongo_db.mongo_create_db(mongo_db_name1, mongo_db_collection, mongo_db_document)35 mongo_db.mongo_create_db(mongo_db_name2, mongo_db_collection, mongo_db_document)36 if os.sep == '\\':37 runner += '.bat'38 execute_tests(runner, args)39 mongo_db.shutdown()40 return process_output()41def execute_tests(runner, args):42 if not os.path.exists(env.RESULTS_DIR):43 os.mkdir(env.RESULTS_DIR)44 command = [runner] + [arg % ARG_VALUES for arg in ROBOT_ARGS] + args + [env.ACCEPTANCE_TEST_DIR]45 print ''46 print 'Starting test execution with command:\n' + ' '.join(command)47 syslog = os.path.join(env.RESULTS_DIR, 'syslog.txt')48 call(command, shell=os.sep == '\\', env=dict(os.environ, ROBOT_SYSLOG_FILE=syslog))49def process_output():50 print51 if _has_robot_27():52 call(['python', os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),53 os.path.join(env.RESULTS_DIR, 'output.xml')])54 rebot = 'rebot' if os.sep == '/' else 'rebot.bat'55 rebot_cmd = [rebot] + [arg % ARG_VALUES for arg in REBOT_ARGS] + \56 [os.path.join(ARG_VALUES['outdir'], 'output.xml')]57 rc = call(rebot_cmd, env=os.environ)58 if rc == 0:59 print 'All critical tests passed'60 else:61 print '%d critical test%s failed' % (rc, 's' if rc != 1 else '')62 return rc63def _has_robot_27():64 try:65 from robot.result import ExecutionResult66 except:67 return False68 return True69def _exit(rc):70 sys.exit(rc)71def _help():72 print 'Usage: python run_tests.py python|jython [options]'73 print74 print 'See README.txt for details.'75 return 25576if __name__ == '__main__':77 if not len(sys.argv) > 1:78 _exit(_help())79 interpreter = sys.argv[1]80 args = sys.argv[2:]...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1# Copyright 2008-2015 Nokia Networks2# Copyright 2016- Robot Framework Foundation3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""The root of the Robot Framework package.16The command line entry points provided by the framework are exposed for17programmatic usage as follows:18 * :func:`~robot.run.run`: Function to run tests.19 * :func:`~robot.run.run_cli`: Function to run tests20 with command line argument processing.21 * :func:`~robot.rebot.rebot`: Function to post-process outputs.22 * :func:`~robot.rebot.rebot_cli`: Function to post-process outputs23 with command line argument processing.24 * :mod:`~robot.libdoc`: Module for library documentation generation.25 * :mod:`~robot.testdoc`: Module for test case documentation generation.26 * :mod:`~robot.tidy`: Module for test data clean-up and format change.27All the functions above can be imported like ``from robot import run``.28Functions and classes provided by the modules need to be imported like29``from robot304.libdoc import libdoc_cli``.30The functions and modules listed above are considered stable. Other modules in31this package are for for internal usage and may change without prior notice.32.. tip:: More public APIs are exposed by the :mod:`robot.api` package.33"""34import sys35import warnings36from robot304.rebot import rebot, rebot_cli37from robot304.run import run, run_cli38from robot304.version import get_version39# Avoid warnings when using `python -m robot.run` with Python 3.5.2 or newer.40# https://github.com/robotframework/robotframework/issues/255241if not sys.warnoptions:42 warnings.filterwarnings('ignore', category=RuntimeWarning, module='runpy')43__all__ = ['run', 'run_cli', 'rebot', 'rebot_cli']...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Robotframework automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful