如何将JSON选项卡设置为SOAP UI开源中响应的默认视图



我正在使用SOAP UI开源来进行REST API测试。我想将" JSON选项卡"设置为响应的默认视图。

我得到的响应已经将content-type设置为'application/json'。它显示XML选项卡,我需要单击JSON以查看响应。有什么办法可以实现这一目标?

我正在使用SOAP UI开源版本5.4.0。

您可以使用蛮力拆卸脚本来执行此操作。我在项目级别上有一个拆卸脚本,该脚本打开了所有测试步骤,切换到"原始"视图并进行屏幕截图。刚刚通过将其粘贴到TestCase拆卸脚本中对FLIKR样本API进行了测试。

运行测试案例并开关视图后,它将打开所有测试步骤。'selectView'函数具有整数(0-4?)或字符串"源"," JSON响应"," HTML响应"或" RAW"在SOAPUI 5.5和5.2.1

中测试了此问题

对于您的情况,每个测试案例单个测试案例基本上允许使用所需响应选项卡打开视图。

import com.eviware.soapui.support.editor.Editor
import java.awt.Component
def getContainers(Component c) 
{
    Component[] subC = c.getComponents()
    for (Component d : subC) 
    {
        String editorClassName = d.getClass().toString()
        if (editorClassName.contains("ResponseMessageEditor")) 
        {
            ((Editor)d).selectView("JSON Response")
        }
    getContainers(d)
    }
}
def uiSupport = com.eviware.soapui.support.UISupport
for (tStep in testCase.testStepList) {
    def panel = uiSupport.showDesktopPanel(tStep)
    com.eviware.soapui.SoapUI.desktop.maximize(panel)
    getContainers(panel)
}

最新更新