如何在 Groovy 中调用变量?
How to call a variable inGroovy?
我正在尝试调用 groovy 中的一个变量。
我的变量是来自 soapui
的 属性 值
所以我试试这个:
我想打开这个页面:http://www.google.com/trends/2014/
我的 属性 值是 2014 年。
def Year = testRunner.testCase.testSuite.getPropertyValue( "Year" )
java.awt.Desktop.desktop.browse "http://www.google.com/trends/"+Year+"/"
我不知道如何调用 url 中的变量 Year,谁能帮帮我。
这是正确的吗?
当我 运行 代码时出现此错误:groovy.lang.MissingMethodException: No signature of method: java.awt.Desktop.browse() is applicable for argument types: (java.lang.String) values:[http://www.google.com/trends/2014/] Possible solutions: browse(java.net.URI), isCase(java.lang.Object),
使用([Ljava.lang.Object;)
谢谢
浏览需要一个 uri,而不是一个字符串...只是做
def Year = testRunner.testCase.testSuite.getPropertyValue( "Year" )
java.awt.Desktop.desktop.browse(new URI("http://www.google.com/trends/$year/"))
我正在尝试调用 groovy 中的一个变量。 我的变量是来自 soapui
的 属性 值所以我试试这个:
我想打开这个页面:http://www.google.com/trends/2014/ 我的 属性 值是 2014 年。
def Year = testRunner.testCase.testSuite.getPropertyValue( "Year" )
java.awt.Desktop.desktop.browse "http://www.google.com/trends/"+Year+"/"
我不知道如何调用 url 中的变量 Year,谁能帮帮我。 这是正确的吗?
当我 运行 代码时出现此错误:groovy.lang.MissingMethodException: No signature of method: java.awt.Desktop.browse() is applicable for argument types: (java.lang.String) values:[http://www.google.com/trends/2014/] Possible solutions: browse(java.net.URI), isCase(java.lang.Object),
使用([Ljava.lang.Object;)
谢谢
浏览需要一个 uri,而不是一个字符串...只是做
def Year = testRunner.testCase.testSuite.getPropertyValue( "Year" )
java.awt.Desktop.desktop.browse(new URI("http://www.google.com/trends/$year/"))