How to run .py file in robot-framework

1,011 views
Skip to first unread message

Basavraj R

unread,
Aug 29, 2022, 7:48:45 PM8/29/22
to robotframework-users
Hi,

I have one .py file --- in .py file contain script of connect server using paramiko module. i.e 100 + no of line of code. (contains one class in that 4-5 functions)
and for UI automate i am using robot framework.. so before start UI automation i need to run .py file... once .py file run completed, i vll get some output from server .. so i assigned to one variable as RAW i need to use that RAW in robot framework.. how could we do that 

need to do--- 
1)run .py file from robot framework 
2) 1st .py file should run then UI part 

Note-- i tried with Run Process, importing .py file but getting error for importing paramiko module.. if we remove paramiko .. it working..other functions...
   
eg---.py

from datetime import datetime

class Test4:
def cur_time(self):
time = datetime.now().strftime("%H:%M:%S")
return time

 
Robot framework-----
*** Settings ***
Library SeleniumLibrary
Library Test4.py

*** Test Cases ***
Class : Time
${Result} Cur time
log to console ${Result}



Gourav Soni

unread,
Aug 31, 2022, 8:02:21 PM8/31/22
to rbasa...@gmail.com, robotframework-users
Hi,

You can try with below solution

Solution 1
You can write the first test case in a robot file that will run a python file using the run process, Add one more function in this python file to get data into excel. Once this test case passes excel will have data, then you can use this Excel data in robot test cases using excel lib or using python custom function.

Solution 2
You can write the first test case in a robot file that will run a batch file, in this batch file you can run a schedule task which will run your python file and then you can store data in Excel file through this python script  and use this Excel data in robot test cases.
(you will need to create a schedule task first and give python file path in it and use this schedule task name in batch file to run) 

Best Regards
Gourav



--
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 view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/e8878be4-95e0-4da8-8772-d23c125e1b78n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages