2

Currently I'm using Eclipse with Nokia/Red plugin which allows me to write robot framework test suites. Support is Python 3.6 and Selenium for it. My project is called "Automation" and Test suites are in .robot files. Test suites have test cases which are called "Keywords".

Test Cases

Create New Vehicle

Create new vehicle with next ${registrationno} and ${description}
Navigate to data section

Those "Keywords" are imported from python library and look like:

@keyword("Create new vehicle with next ${registrationno} and ${description}")
def create_new_vehicle_Simple(self,registrationno, description):
    headerPage = HeaderPage(TestCaseKeywords.driver)
    sideBarPage = headerPage.selectDaten()
    basicVehicleCreation = sideBarPage.createNewVehicle()
    basicVehicleCreation.setKennzeichen(registrationno)
    basicVehicleCreation.setBeschreibung(description)
    TestCaseKeywords.carnumber = basicVehicleCreation.save()

The problem is that when I run test cases, in log I only get result of this whole python function, pass or failed. I can't see at which step it failed- is it at first or second step of this function.

Is there any plugin or other solution for this case to be able to see which exact python function pass or fail? (of course, workaround is to use in TC for every function a keyword but that is not what I prefer)

4
  • it's a duplicate of this and other threads. Please search the forum before you put the question. stackoverflow.com/questions/43974104/… Commented Jun 5, 2017 at 8:35
  • 1
    It's not the same issue. If I have found solution in forum, why would I made trouble to register and write this question? Please read carefully problem and compare with other issue before you mark it as duplicate. Once more, issue which you mentioned and solution there are not helpful for my problem. Commented Jun 5, 2017 at 9:20
  • so what are you saying is this solution which you have accepted is not same as provided by two guys in the post you mentioned? please read the guidelines before putting the question Commented Jun 5, 2017 at 9:29
  • it is not straight forward that linked questions relates to the same root issue. Same solution does not mean that initial problems are the same.I would even said this question is better worded for future search than other as here you have everything which describes usual problems while debugging Robot - debug works only on Robot level,how to dive into Python stuff. Commented Jun 5, 2017 at 10:04

2 Answers 2

3

If you need to "step into" a python defined keyword you need to use python debugger together with RED.

This can be done with any python debugger,if you like to have everything in one application, PyDev can be used with RED.

Follow below help document, if you will face any problems leave a comment here.

RED Debug with PyDev

Sign up to request clarification or add additional context in comments.

4 Comments

I have installed Red by using eclipse marketplace. First regarding environment setup: I didn't have option Python Nature when right clicking on project. All other step described under that link I did and at end I debugged run test suite by using new created robot debug configuration but still get same log/report, only detailed to robot keyword but black box to python functions. Should I run debug on the python library level?
Python/PyDev nature is only available after you install PyDev into Eclipse. Install it to RED/Eclipse and off you go. If you would use pydevd (pydev debuger) directly from Eclipse folder,you need to update path in script: github.com/nokia/RED/blob/master/src/RobotUserScripts/… on line 91
You still need to place debug breakpoint inside py files, python debugger will provide stack traces of what is happening.
just to inform you that somehow it works now. All I did was to delete older debug configuration and create new one ...
2

If you are wanting to know which statement in the python-based keyword failed, you simply need to have it throw an appropriate error. Robot won't do this for you, however. From a reporting standpoint, a python based keyword is a black box. You will have to explicitly add logging messages, and return useful errors.

For example, the call to sideBarPage.createNewVehicle() should throw an exception such as "unable to create new vehicle". Likewise, the call to basicVehicleCreation.setKennzeichen(registrationno) should raise an error like "failed to register the vehicle".

If you don't have control over those methods, you can do the error handling from within your keyword:

@keyword("Create new vehicle with next ${registrationno} and ${description}")
def create_new_vehicle_Simple(self,registrationno, description):
    headerPage = HeaderPage(TestCaseKeywords.driver)
    sideBarPage = headerPage.selectDaten()
    try:
        basicVehicleCreation = sideBarPage.createNewVehicle()
    except:
        raise Exception("unable to create new vehicle")

    try:
        basicVehicleCreation.setKennzeichen(registrationno)
    except:
        raise exception("unable to register new vehicle")

    ...

13 Comments

even in this case, when I run my test case I will get general error message for whole keyword ElementNotVisibleException: Message: element not visible
Its robot based test suites, tests and keywords and run with python -m robot
@domoni: it is up to you to make sure you emit good error messages. There's nothing in robot framework or in python that is preventing you from emitting useful error messages.
in this case I am limited and yes robot framework prevent me currently to get correct debug and correct pointing to problem
in previous comment I wrote that I added "try / except" into my python script code as you suggested and still get log error which I posted you in previous comments and always got only message what went wrong in keyword, element not found, element not visible, document error, type error... but not where it happened at which line and also I didn't get messages which I defined under exceptions which I wrote (once more in the way you suggested). Please read history.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.