AutoTester213
AutoTester213

Reputation: 2862

Return Value from Method in Python using Robot Framework

So lets say i have this method in python

def get_data(notificaition):
    print("Notification Recived: ", notificaition)

And then i Have another method that recives a event and gets the value of that event.

def verify_singal_r():
    with Session() as session:
        connection = Connection("http://example/signalr", session)
        print(connection)
        logging.info("got the connection")
        presenceservice = connection.register_hub('MyHub')
        connection.start()
        def print_error(error):
            print('error: ', error)


        connection.error += print_error

        # TODO: NEED TO ADD POST REQUEST HERE
        presenceservice.client.on('Notified', get_data)
        connection.wait(10)

Once the Keyword Verify_Signal runs I get the values I need and i print them onto the console

How can I use the value of the get_data in robot framework?

I tried to simply use

*** Test Cases ***

Get Event Back
     verify_singal_r
     get_data

But that does not work as get_data expects an argument.

Upvotes: 1

Views: 2086

Answers (2)

sebastianciupinski
sebastianciupinski

Reputation: 1

Your method

def get_data(notificaition):
    print("Notification Recived: ", notificaition)

does not return anything, so robot framework keyword will not return anything too.

Upvotes: 0

pankaj mishra
pankaj mishra

Reputation: 2615

your function

def get_data(notificaition):
    print("Notification Recived: ", notificaition)

Expects an argument

However when you are calling this in robot framework

*** Test Cases ***

Get Event Back
     verify_singal_r
     get_data

You are not providing any argument to it.

You can try something like this

*** Variables ***
${notification}    Test
*** Test Cases ***

Get Event Back
     verify_singal_r
     get_data    ${notification}

This will solve your problem.

Upvotes: 2

Related Questions