Ask a Question

ReadyAPI- download a textfile from a URL with groovyscript

SOLVED
AAB
Regular Contributor

ReadyAPI- download a textfile from a URL with groovyscript

Hello,

 

I have looked at a dozen of possibilities online to download a textfile from a website, but none is actually OK for my case.

What I need to do:

Go to the website that contains a bunch of logfiles (extension = paldata but actually can be saved as textfile)

search for a file with an ID in the string equal to, let's say, 

XyLQpIfwhDv90uazxe1kwQAAABc

e.g. 20200730-XyLQpIfwhDv90uazxe1kwQAAABc.paldata

Open the file and read it.

Search for "fsbTransactionid".

If it's not present --> error message 

<Response-code>404</Response-code>

if it's present read it and stash it in a variable

I would like to do that for different ID's in the file.

Now, as I found a lot "BuilderHTTPs" methods, I/O Read and Write methods that I've tried, it seems that I'm not able to handle the total picture. and the installation of a standalone selenium didn't work for me neither. (cfr. to another post of mine)

Does somebody have another idea please?

@nmrao ? @msiadak ? @NBorovykh @Anastasia ?

Thanks in advance

AboveAndBeyond

22 REPLIES 22
richie
Community Hero

Hey @AAB,

In case the other lads/ladies dont come up with anything, i was wondering what youre front end automation skills are like as this equates to what is pretty standard fair front end auto....i.e. im thinking about doing it in java which obviously ReadyAPI! does support.

If youre not sure how to do it, you could record the screen actions using something like seleniumIDE or Katalon (browser plugin not the app), then export the record test as java code. Youve then got the basics of your search a page for a link, select the link on the page and download a file.
You could add some groovy ( or java) to parse the file, and find what youre looking for and assert against it. Obviously in your test case before the groovy step containing the extracted java and groovy youd need a GET request to retrieve the relevant page.

I know it sounds a bit of a bodge, and i'm pretty sure you might need some front end auto import declarations in your script etc., but if you have any front end auto experience this shouldnt be too difficult at all...im fairly confident even i could do this and your coding appears better than mine.

Just a suggestion!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

Another option might be using an "HTTP Request" test step to browse to and retrieve the file, not 100% sure if that'd work. From there, if it does, you could potentially use groovy to parse the text file from the HTTP response?




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
HimanshuTayal
Community Hero

@AAB :

 

For getting data from UI/WebPage, you can try selenium and selenium jars are supported in soapui, just follow below link and add all the jars into soapui/bin/ext folder.

 

https://www.guru99.com/selenium-tutorial.html


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
AAB
Regular Contributor

@richie 

Thanks buddy, do agreed to do this with recording tools but Katalon gave me a headache as it was complaining about the version of my Chrome.  I've looked for that on the internet and I was not the only one. As result I gave up that thought and put my problem here 🙂 

Nevertheless, I'll give it a try next week. I'm working on different projects for the moment, so no time today. I'll come back if I have a solution in anyway.

 

cheers!

AboveAndBeyond

AAB
Regular Contributor

Hi @msiadak 

 

mmm, I didn't thought of that one! 😄 thanks, I can give that a try and let you know.  😉 

AAB
Regular Contributor

Hello @HimanshuTayal 

 

Thanks for the link. I'll give it a try next week.

 

Cheers,

AboveAndBeyond

http request step? If that'll help then great, but i always thought the http request step was very similar to the REST step....i.e. youre constrained to the http verb methods????
If it works, can you post how you managed it? Cos i always like being educated!

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

I'll admit, @richie, I was theorizing as I've never used that particular sort of test step before. So I very well may be wrong, but figured it's worth a shot?




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

@msiadak, hey man....i certainly aint knocking the idea, i was just highlighting that i don't know how to do it using the http step so would welcome the education!

Nice one!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
cancel
Showing results for 
Search instead for 
Did you mean: