在Flask上运行机器人测试时,日志不起作用

时间:2018-07-27 06:04:36

标签: flask robotframework

我尝试创建一个API来运行机器人框架测试

我的代码如下:

1个Flask应用程序:

from flask import Flask
from testrob import test_robot
from flask import request
from robot import run
app = Flask(__name__)

@app.route("/test")
def test():
  request_args = request.args
  rc = test_robot(request_args)
  return str(rc)

def test_robot(request_args):
  params = parse_reqest_args(request_args)  # logic goes elsewhere
  rc = run(robot_script_path, test=params["testname"], variable=params["inner_args"])
  # robot_script_path is the ./test/robot_test/xxx.robot test file, 
  # params["inner_args"] is the params for the test like  ["scopename:common_test", "suitename:test_login", "testname:OpenBrowser"]

if __name__ == '__main__':
  app.run(host="0.0.0.0")

当我点击网址127.0.0.1:5000/test吗?&arg1 = xx&arg2 = xx&arg2 = xx 该测试将运行并生成日志,但日志不完整。

  

Screenshot of Incomplete log

日志详细信息:

Key Word SeleniumLibrary . Open Browser ${baseurl}, Chrome
    Documentation:  
    Opens a new browser instance to the given url.
    Start / End / Elapsed:  20180727 13:22:17.734 / 20180727 13:22:33.846 / 00:00:16.112

但是,如果创建文件run.py并运行它,则日志是完整的

 from robot import run
 robot_script_path = "./test/robot_test/foo.robot",
 testname= "test_login"
 inner_args=["browser:Chrome", "url:https://www.google.com"]
 rc = run(robot_script_path, test=testname, variable=inner_args)

Screenshot of complete log

日志详细信息:

Key Word SeleniumLibrary . Open Browser ${baseurl}, Chrome
    Documentation:  
    Opens a new browser instance to the given url.
    Start / End / Elapsed:  20180727 13:22:17.734 / 20180727 13:22:33.846 / 00:00:16.112
    13:22:17.735    INFO    Opening browser 'Chrome' to base url 'https://www.google.com'.

如果在Flask中调用测试,则最后一行日志信息将丢失

0 个答案:

没有答案