我正在使用Soapui的Groovy步骤.以下代码运行良好但似乎很长且重复:
if(response.comp.type[3] == "value1")
log.info ("value1 is present")
else
log.info ("value1 is not present")
if(response.comp.bucket[3] == null)
log.info ("bucket = null")
else
log.info ("bucket is not null")
if(response.comp.cycle[3] == "new")
log.info ("settings cycle = new")
else
log.info ("settings cycle is null")
Run Code Online (Sandbox Code Playgroud)
是否可以在一次测试中执行相同操作,而不是在每一行上重复IF和ELSE.我试过TRY CATCH,但我不能有错误的堆栈跟踪.
任何人都可以帮助减少代码.谢谢
我想在Project级别设置属性,使用我的groovy代码我可以在TestCase级别设置属性.如何在Project级别设置属性
这是我的代码:
import groovy.json.JsonSlurper
responseContent = testRunner.testCase.getTestStepByName("TestStepName").getPropertyValue("response")
slurperresponse = new JsonSlurper().parseText(responseContent)
slurperresponse.id.toString()
log.info (slurperresponse.id.toString())
property_name = 'a'
def idProperty = setupTestCase.getProperty(property_name).toString()
setupTestCase.setPropertyValue('a',slurperresponse.a.toString())
Run Code Online (Sandbox Code Playgroud)
这里我从TestStepName的响应中设置TestCase属性"a".我正在使用Soapui.
谢谢
我有一个按钮的以下代码:
<div class="buttons">
<button class="btn dialog-confirm btn-primary" style="margin-left: 4px;">Confirm</button>
<button class="btn dialog-cancel" style="margin-left: 4px;">Cancel</button>
</div>
Run Code Online (Sandbox Code Playgroud)
有两个按钮是确认,另一个是取消我可以找到XPath按钮,但我不想使用XPath.在这种情况下是否有其他方法可以找到按钮元素?
我试过这个:
driver.findElement(By.className("btn dialog-confirm btn-primary")).click();
Run Code Online (Sandbox Code Playgroud)
它没有找到按钮谢谢你的帮助
我想从数据类型为clob的表中选择数据.所以resut就像oracle.sql.CLOB@12fe54d我想将数据显示为表中出现的字符串.
在groovy我试过这个:
rowTest = sql.firstRow("select name from table where id=10")
clobTest = (oracle.sql.CLOB)rowTest[0]
byte_stream_test = clobTest.getBinaryStream()
if( byte_stream_test == null ) { println "Test: Received null stream!" }
byte[] byte_array_test = new byte[10]
int bytes_read_test = byte_stream_test.read(byte_array_test)
print "Read $bytes_read_test bytes from the clob!"
sql.connection.close()
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
---- A working test of writing and then reading a blob into an Oracle DB ---
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: oracle.sql.CLOB.getBinaryStream() is applicable for argument types: () values: [] …Run Code Online (Sandbox Code Playgroud) 我在Soapui有一个项目:TestSuite1,TestCase1和一些TestStep,如Groovy测试,创建Rep和延迟
我想要做的是使用groovy执行Create Rep TestStep.我试过这个:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = testCase.getTestStepAt(0);
def testStep = testCase.getTestStepByName("Create Rep");
def testStep = testCase.testSteps["Delay"];
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
testStep.run(testRunner, testStepContext);
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script15.groovy: 27:
The current scope already contains a variable of the name testStep @ line 27, column 5.
def testStep = testCase.getTestStepByName("");
^ org.codehaus.groovy.syntax.SyntaxException: The current scope already contains a variable of the name testStep @ line …Run Code Online (Sandbox Code Playgroud) 我正在使用Soapui,我想添加一个常规代码来声明json响应中的某些元素。
我如何将groovy的if else语句用于以下代码:
def jsonPayload = new File("C:/temp7/file.js").text
import groovy.json.JsonSlurper
def slurper = new JsonSlurper()
def response = slurper.parseText(jsonPayload)
if (assert response.comp.type[0] == "header")
println 'header is present'
else 'header is not present'
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,我遇到错误org.codehaus.groovy.control.MultipleCompilationErrorsException
谢谢