Contributions
XPath in groovy script: How to use a variable in contains() function?
Hello, I struggle with using a groovy variable inside a contains() function of XPath statement within a SoapUI property. Having this xml: <ResultSet> <Row> <Id>1</Id> <Description>Something1</Description> </Row> <Row> <Id>2</Id> <Description>Something2</Description> </Row> </ResultSet> This works: log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(.,"thing2") ]/Id}'); Result: 2 (which is correct). These syntaxes don't work: groovyVariable = "thing2" log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(., groovyVariable) ]/Id}'); log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(., ${groovyVariable}) ]/Id}'); log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(., "${groovyVariable}") ]/Id}'); log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(., "$groovyVariable") ]/Id}'); log.info context.expand('${JdbcRequest#ResponseAsXml#//Row[ Description/contains(., $groovyVariable) ]/Id}'); Result: 1 (first element in the structure) or nothing. Is there a way how to resolve a groovy variable inside an XPath function please? I bet there must be a combo I didnt try and which is the correct one :). I use ReadyAPI 2.1.0. Thank you, ZuzanaSolved7 years agoPlace ReadyAPI QuestionsReadyAPI Questions5KViews0likes2CommentsProject xml corrupted if SoapUI not closed correctly
Hi, There is a known bug when after system failure, SoapUI corrupts already saved project xml. https://community.smartbear.com/t5/SoapUI-Open-Source/Error-Running-Soapui/m-p/7046#M4025 I encountered this problem twice. As a lesson from the first experience (when just several characters have been broken and I was able to fix it), I have setautomatic creation of backup folder in Preferences / UI settings and also synced the backup folderwithcloud repository. As a result of the second failure, I have THREEsets of corrupted files (this time full of NULLs and not recoverable): the actual project files,the automatic backups and even the cloud backups. My recommendation to users: - Create regular snapshots (win backup), or regularly SAVE the Project AS different file. Projects which are not opened, cannot be broken with this bug. - Uncheck Preferences / UI settings /"Save all projects on exit". Unfortunately, I have no solution for already broken files. I appreciate any advice here. Brainstormig about possible solutions... Im not familiar withjava development so may be totally out of box :-) - Change the backup logic to create new file each time, instead of overwriting the original one. There can be, for example, three latest versions of project xml as a result of automatic backup; further backup will remove the oldestversion and add a newest one. - Or, change the logic SoapUI handles the project in memory. Does it create a "local copy" or manipulates the actual file "directly"? If not closed correctly, do not try to save latest changes (let the project file untouched)? - Saving process handled as a kind of a transaction? Validate a file before try to save it on file system? Situations when this bug can be encountered with high probability: - Windows cannot be resumed from Sleep or Hibernate mode and hard restart or switch-off is needed. - Computer off because of power outage. Unexpected system failure can break new/not saved data (and no one complains) but it should never break old, saved and backup-ed ones, imho. I would be great if SoapUI could prevent this rare, however critical issue. Thank you and have a nice day, Zuzana2.2KViews0likes3Comments