Forum Discussion
As far as I understand, you need to access a file from an URL provided by the HTML response of your request.
I used to parse some HTML content with Jsoup to extract data or make some assertions.
Once you get the path you cab easily access the file or its content.
By the way could you provide an exemple of your HTML content so we could try to do something ?
Thanks.
Manual Testing approach
I am hitting a request in soap UI, Soap UI is providing me some respone.
But internally API is creating 6 json file in the specific repository location with the current date and time name which looks like link, then I am clicking on file to download it and verifing the contents inside the file.
I wanted to automate this part through soap UI.
Hope I am able to explain you
- ZDGN4 years agoContributor
Hi sparrowenclave,
Here is a sample script to browse a directory containing json files and open each to find a specific node.
import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import static java.util.stream.Collectors.toList; File newFile; String FolderPath = "<insert your path here>"; File selectedDirectory = new File(FolderPath); List<Path> paths = new ArrayList<>(); try { paths = Files.walk(Paths.get(new File(selectedDirectory.getPath()) .getAbsolutePath())) .filter(p -> p.toFile().isFile()) .collect(toList()); } catch (IOException e) { e.printStackTrace(); } for (Path path : paths) { newFile = new File(path.toString()); ObjectMapper mapperFileSource = new ObjectMapper(); JsonNode rootNode = null; try { rootNode = mapperFileSource.readTree(newFile); } catch (IOException e) { e.printStackTrace(); } JsonNode searchNode = rootNode.findValue("<insert a node name here>"); if (searchNode != null) { log.info(searchNode.textValue()); // You can add assertions here } }
It is just an example of what can be done.
Keep in min you'll need jackson's library.
Hope this will help.David.
- ZDGN4 years agoContributor
You could try some groovy script to access your files if you already know the location.
By browsing the directory, just loop for opening each file and make assertion on the content.
Is that what you're looking for ?
- sparrowenclave4 years agoOccasional ContributorYes ,
I am looking this solution, If you can help , It will be great help by providing some scripts.
Related Content
- 8 years ago
Recent Discussions
- 3 days ago