Forum Discussion
Hello ibright,
ibright wrote:
I used Get Data to get the project property and it automatically created this:
def aPIresultsfolder = context.expand( '${#Project#API results folder}' )
How do I get it to work with this part of the script that I had already set up:
new File(folderPath).eachFile (FileType.FILES) { file ->
//Delete file if file name contains Forward NDF errors
if (file.name.contains('Forward NDF errors')) file.delete()
}
new File(aPIresultsfolder).eachFile (FileType.FILES) { file ->
//Delete file if file name contains Forward NDF errors
if (file.name.contains('Forward NDF errors')) file.delete()
}
- richie10 months agoCommunity Hero
Hey TNeuschwanger
I saw this post by ibright originally when he posted and didn't reply cos I wasn't sure about the answer.
Part of why I didn't answer is cos I suck at coding, but also I was wondering - the 'aPIresultsfolder' variable is generated within a test case via a Get Data test step - so the variable is generated at test step so available at test case level. If the script ibright is using is a 'Setup Script' on say the test suite or test case level - would the 'aPIresultsfolder' variable be picked up when the 'Setup Script' executes before the test suite, test case and relevant test step has fired?
Thanks man TNeuschwanger - I'm asking for my education - it all helps, you know?
Also - ibright - I'm not picking holes here - but if in future you published the whole script rather than excerpts - that can help tremendously resolve any queries the reader of the post might have.
Cheers to both!
Rich
- TNeuschwanger10 months agoChampion Level 1
Hello richie,
Like you, I needed to make a few assumptions about the question... Since it is ibright very first post, I though making some assumptions was perfectly ok. 🙂
The 'Get Data' feature is a menu item available from the groovy script editor (Setup Script, TearDown Script, Groovy Test Step) by right clicking anywhere in the text editor area. I assumed that is where ibright acquired and defined the variable. Since the property expansion references a 'Project' level variable, it should be available whenever and wherever the line of code is executed.
def aPIresultsfolder = context.expand( '${#Project#API results folder}' )
ibright appears to want to use that variable very soon in their logic but might just need the syntax knowledge on how to use the value in the part of the script they already set up.So, richie, I think the short answer is yes. aPIresultsfolder is available for that project property expansion when requested. Good question for followup.
Regards,Todd
- richie10 months agoCommunity Hero
Hey ibright
regarding your concern about publishing the full path within a groovy script on an unsecured web site. I'm assuming it was from a security concern more than anything else?
For future considerations - that's not the sort of thing any person of an evil hacking type persuasion can use without more info than you have provided. I once spoke to a Security Technical Architect about the stuff I could post on forums and what he said I've summarised below.
ALWAYS hide the domain that you're hitting in your tests within any screenshot you provide - but without that - no one would be able to do anything to access your resource and if they don't know the host, then they can't find the endpoint you are discussing in your posts to do anything.
Hence why providing an API's URI (the URL MINUS the HOST portion of the full request) (and even a payload) you are working with in a screenshot is fine, but no help to anyone as long as you make sure the domain (the host part of the URL) you're hitting is obfuscated. Other than that - you haven't really got anything to worry about from a security perspective.
The only thing I would say is, if you are providing screenshots - make sure that you do look over the whole image to ensure the host/domain details aren't displayed somewhere else on the screen. With ReadyAPI depending on what is selected, it's quite possible the host/domain details are displayed in multiple locations rather than just one place.
Hey TNeuschwanger - cheers Todd - appreciate the explanation - I keep dipping in and out of coding/automation which makes my coding skills totally sucky - I mean it's like anything - if you don't use it, you lose it and I definitely lost it! So yeah - cool man - cheers for the extra help! 😉
Cheers to both!
Rich
- ibright10 months agoNew Contributor
Sorry, I was wary of including the folder directory that had been hard coded into the script.
Related Content
- 4 years ago
- 4 years ago
- 4 years ago