[英]how to run a robot framework script with python 3.7 from the terminal
[英]Unable to Run python script from Robot framework
示例.py
import json
def getElementCount(jsonObj):
data1 = json.dumps(jsonObj)
item_dict = json.loads(data1)
countElement=(item_dict['one'])
print len(countElement)
return countElement
機器人框架
Library Sample.py
** Test Cases ***
[TC-001]-Registering a device with INVALID SUBSCRIBER name
${ResponseJson}= Customer Method API Call ${host} ${apivalue}
${value} = Call Method getElementCount ${ResponseJson}
錯誤描述
它不起作用,有人可以幫忙解決上述問題嗎
我想從機器人框架調用上述 python 方法,並將 ${ResponseJson} 值傳遞給上述 python 方法。 並在識別長度結果后返回機器人框架。
我已經瀏覽了下面的鏈接,但理解調用方法的含義。 http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Call%20Method
Call method
用於在對象上調用方法。 導入庫時,沒有對象。
將模塊導入為庫時,每個函數都將成為關鍵字。 因此,您可以直接調用getElementCount
:
** Test Cases ***
...
${value} = getElementCount ${ResponseJson}
我在導入 paramiko 時遇到問題...通常沒有 paramiko 會起作用..對於下面的代碼,找不到名稱為“getconnectionconfig”的關鍵字。 Test4.robot---> *** 設置 *** 庫 SeleniumLibrary 庫 Test4.py
*** 測試用例 *** Class:測試 ${Result} = getconnectionconfig 日志到控制台 ${Result}
測試4.py---->
from datetime import datetime
import paramiko
global ssh, channel
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
def cur_time():
return datetime.now().strftime("%H:%M:%S")
cur_time()
print(cur_time())
def getconnectionconfig():
global channel
ssh.connect('192.168.1.1', username='root', password='root')
channel = ssh.invoke_shell()
print("Current Time is : [" + cur_time() + "] Connection Successful with
Server")
getconnectionconfig()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.