Debug Skills

Reference Links

robotframework-debuglibrary 0.3

https://pypi.python.org/pypi/robotframework-debuglibrary

RobotFramework debug library and an interactive shell

Introduction

Robotframework-DebugLibrary is A debug library for RobotFramework, which can be used as an interactive shell(REPL) also.

Installation

Installation is done just as for any other Python library. Using the pip oreasy_install command from setuptools is the easiest.

To install using pip:

pip install robotframework-debuglibrary

To install using easy_install:

easy_install robotframework-debuglibrary

Usage

You can use this as a library, import DebugLibrary and call Debug keyword in your test files like this:

*** Settings ***
Library         DebugLibrary

** test case **
SOME TEST
    # some keywords...
    Debug

Or you can run it standalone as a RobotFramework shell:

$ rfshell
[...snap...]
>>>>> Enter interactive shell, only accepted plain text format keyword.
> log  hello
> get time
< '2011-10-13 18:50:31'
> import library  String
> get substring  helloworld  5  8
< 'wor'
> selenium  http://www.douban.com/
import library  SeleniumLibrary
start selenium server
open browser  http://www.douban.com/
> Ctrl-D
>>>>> Exit shell.


Add Breakpoint in Library

import sys, pdb; pdb.Pdb(stdout=sys.__stdout__).set_trace()

BuiltIn.Log and Print

from robot.libraries.BuiltIn import BuiltIn

Log of info levelis output to report.html:

BuiltIn().log(message = CM_NAME + " initialize" + "Initializing  [%s] " % (self.ip_addr), level = "INFO")

Warn message isoutput to console window:

BuiltIn().log(message = CM_NAME + " initialize" + "Initializing [%s] " % (self.ip_addr), level = "WARN")

Print Warning Message:

print("*WARN* Test Message") same effect as log as warnlevel.

Add Debug Option in CommandLine

For pybot,--debugfile <file> can be added, and a debug file will be created.

-b, --debugfile <file>

 

A debug file that is written during execution.

pybot -v RootTarget:D:\Rwbot -vProductTarget:D:\Rwbot\targets\ap_qa_auto --variablefiletargets/ap_qa_auto/resources/variables/VAR.py --include"2g&mcast"--debugfile debug.log targets/ap_qa_auto/testsuites/qos

發佈了52 篇原創文章 · 獲贊 2 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章