Hi Alessandro,
You're right... Groovy's the best way to use webtest !! ;-)
So, there's several possibilities :
If you want to copy a Webtest property in a groovy variable in the
script that launches the steps -> it's impossible
you cannot write :
ant.testSpec{
config{
// config here
}
steps{
invoke(url:"bla.com")
storeXPath(xpath:"//my/x/p...@th]",value:"groovy_var")
def variable = groovy_var
}
}
because closures are executed at construction time and not at run-time
but... you can intercept it at the end of the step by writing an ant
step listener like :
ant.getAntProject().taskFinished = {buildEvent -> def task =
buildEvent.task
if
(task.taskType == 'storeXPath'){
def
variable = task.dynamicProperties.groovy_var
}
}
DynamicProperties is the way to exchange variables between Webtest and
Groovy. You can easily add a Groovy Step like
groovy(description:"a way to get variables from webtest","""
def document = step.context.currentResponse.documentElement
def props = step.webtestProperties
def variable = props.groovy_var //groovy_var is the one
from the storeXPath
//and you can rethrow a groovy variable into webtest
def webtest_var = doSomethingWith(variable)
props.putAt("webtest_var_from_groovy",webtest_var)
""")
and then use it in your steps :
setSelectField(xpath:"id('anId')/opti...@value='#webtest_var_from_groovy']")
Hope that helps
Florent
Pingwy
27, rue des arènes
49100 Angers
[email protected] a écrit :
Dear all,
I'm developing testcases in groovy.
Is there a way to copy webTest property values into a groovy variable?
e.g.
excelStoreCellValue( cell:"B4", *property*:"propertyCellB4",
description:"Read cell value from B4" )
Verfying is simple:
verifyProperty(*property*:"propertyCellB4", value:"Periode",
description:"Check property" )
But how to copy?
def myVariable = ????
Any ideas appreciated! :)
Best regards,
Alessandro
_________________________________________________________________
Diese Information ist ausschliesslich fuer den Adressaten bestimmt und
kann vertraulich oder gesetzlich geschuetzte Informationen enthalten.
Wenn Sie nicht der bestimmungsgemaesse Adressat sind, unterrichten Sie
bitte den Absender und vernichten Sie diese Mail. Anderen als dem
bestimmungsgemaessen Adressaten ist es untersagt, diese E-Mail zu
lesen, zu speichern, weiterzuleiten oder ihren Inhalt auf welche Weise
auch immer zu verwenden. Wir verwenden aktuelle Virenschutzprogramme.
Fuer Schaeden, die dem Empfaenger gleichwohl durch von uns zugesandte
mit Viren befallene E-Mails entstehen, schliessen wir jede Haftung aus.
* * * * *
The information contained in this email is intended only for its
addressee and may contain confidential and/or privileged information.
If the reader of this email is not the intended recipient, you are
hereby notified that reading, saving, distribution or use of the
content of this email in any way is prohibited. If you have received
this email in error, please notify the sender and delete the email. We
use updated antivirus protection software. We do not accept any
responsibility for damages caused anyhow by viruses transmitted via email.