How to debug the Robot Framework Test

7,061 views
Skip to first unread message

Abdul Rahman Chaudhari

unread,
Aug 21, 2016, 8:27:03 AM8/21/16
to robotframework-users
Can any body help me in debugging Robot framework test using pdb or some other third party library which Robot supports. I tried using 'Debug' keyword but its not much useful as we cannot do step into, step over like in other tool.

Please let me known if there is any approach for debugging Robot framework test..

Ed Manlove

unread,
Aug 21, 2016, 8:58:39 AM8/21/16
to robotframe...@googlegroups.com
> --

Instead of the standard pdb.set_trace() you need to regain control of
stdout since Robot Framework highjacks it for its output. Try instead

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

With the above line you should still be able to work with pdb as you
normally would. There are a few more hints to debugging that we host on
the Selenium2Library project [1]; although I will note they are geared
more towards those working specifically with the Selenium2Library.

Ed

[1] https://github.com/robotframework/Selenium2Library/blob/master/BUILD.rst




Ed Manlove

unread,
Aug 21, 2016, 9:03:21 AM8/21/16
to robotframe...@googlegroups.com
I will add this is for low level debugging where as you are looking for
more high level debugging which I'm sorry but I don't have any great
suggestions for stepping through keywords, for example.

Ed
Message has been deleted

Ed Manlove

unread,
Aug 21, 2016, 9:35:08 AM8/21/16
to robotframe...@googlegroups.com
If I am debugging my work with a library I will place the set_trace line into the library near the point I am investigating. Using the Selenium2Library as an example I would do something like

    def get_webelements(self, locator):
        """Returns list of WebElement objects matching locator.

        See `introduction` for details about locating elements.
        """
        import pdb,sys; pdb.Pdb(stdout=sys.__stdout__).set_trace()    # <-- added to src/Selenium2Library/keywords/_element.py
        return self._element_find(locator, False, True)

and then use the standard pdb commands. But again this is helpful for debugging specific issues within libraries, generally on a single keyword level, but not very helpful if you are trying to debug a robot test as a whole or across and within multiple keywords. If you are having issues with a robot test you might post your problem to the newsgroup. Generally for debugging at the test level I use the old school technique of logging generally using the Log To Console keyword. You should also use the loglevel command line/RIDE run argument to get more information using the DEBUG value. See the User Guide [1] for more information. So where normally I would run my test typing

pybot my_troublesome_test.robot

instead I would run my tests like

pybot -T --loglevel DEBUG my_troublesome_test.robot

The -T argument timestamps the output files so I can see results over time and the --loglevel DEBUG adds more information to the log.html output file.

Ed

[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-log-level

On 08/21/2016 09:05 AM, Abdul Rahman Chaudhari wrote:
Can you please explain me with some example ?


On Sunday, August 21, 2016 at 5:27:03 AM UTC-7, Abdul Rahman Chaudhari wrote:
Can any body help me in debugging Robot framework test using pdb or some other third party library which Robot supports. I tried using 'Debug' keyword but its not much useful as we cannot do step into, step over like in other tool.

Please let me known if there is any approach for debugging Robot framework test..
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Tatu Aalto

unread,
Aug 22, 2016, 1:11:28 AM8/22/16
to devp...@verizon.net, robotframework-users

Ugh

When debugging a library and if the problem is complex enough that simple print statement here and there doesn't solve the problem, I tend to use winpdb[1]. Regardless of the name, it's a OS independent debugger for the Python and works[2] also with Robot Framework.

-Tatu
Send from my mobile
[1] http://winpdb.org
[2] http://winpdb.org/docs/embedded-debugging/


To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.

Krzysztof Jozefowicz

unread,
Aug 22, 2016, 2:48:51 AM8/22/16
to robotframework-users
Hi

Check out RED Robot Editor debug capabilities, together with Eclipse you can debug Robot tc (also debug tc on remote host), debug Python libs from Robot execution or even debug Robot and Python at the same time.
Debug works as in other IDEs, you set break points (static or based on expression), when break point is hit, you step through tc execution (together with step into underlying KWs),there is a variable value watch which can be overridden in case of need.
How to do it in RED (debug Robot tc):
https://github.com/nokia/RED/blob/master/red_help/user_guide/debug.html.md

Main RED GitHub page:
https://github.com/nokia/RED

If you have any specific questions,please ask here.

K.
RED team

Mukesh Takhtani

unread,
Sep 22, 2016, 11:45:55 AM9/22/16
to robotframework-users

Hi everyone,

It would be good to have debugging features in RIDE (for high level debugging at keyword level, stepping through keywords...).

Is there any plan to add debug features in RIDE, if anyone is aware of it?

Thanks,
Mukesh

--

adam.wyp...@gmail.com

unread,
Oct 4, 2016, 3:46:15 AM10/4/16
to robotframework-users
You have debug feature in RIDE, but is very simple and base on some comments in Your test material like i.e.: Comment PAUSE. So I suggest to use RED, where You can use Eclipse like debugger for RF.

See example:

*** Test Cases ***
Test
            Comment                PAUSE
            Log                    OK
            Log                    OK2
            Log                    DONE!
To post to this group, send email to robotframe...@googlegroups.com.

Mukesh Takhtani

unread,
Oct 9, 2016, 10:07:04 AM10/9/16
to adam.wyp...@gmail.com, robotframework-users
Thanks! This was helpful.

Best,
Mukesh

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.

PaulaM

unread,
Nov 29, 2017, 9:23:45 AM11/29/17
to robotframework-users
Hi 
Is there a RED plugin for Intellij?
Thanks
To post to this group, send email to robotframe...@googlegroups.com.

adam.wyp...@gmail.com

unread,
Nov 30, 2017, 3:12:14 AM11/30/17
to robotframework-users
No RED is plugin for eclipse.
Message has been deleted

ChandraSekhar Pola

unread,
Nov 12, 2020, 12:49:37 PM11/12/20
to robotframework-users
 i am getting the following error using  the statement -- Evaluate    pdb.Pdb(stdout=sys.__stdout__).set_trace()    modules=sys,pdb , in the test case 

Evaluating expression 'pdb.Pdb(stdout=sys.__stdout__).set_trace()' failed: NameError: name '__args__' is not defined nor importable as module

Can anyone help me here how to fix the problem ?

Reply all
Reply to author
Forward
0 new messages