public void saveHar() throws IOException { if(lastHar == null) { throw new IllegalStateException("No har found."); } File baseDir = harDir; if(CollectionUtils.isNotEmpty(harDirStack)) { baseDir = harDirStack.pop(); } File newFile = new File(baseDir, lastName + ".har"); lastHar.writeTo(newFile); }
if(server.getHar()==null){ System.out.println("No Har capture"); } Har har = server.getHar(); if(har==null){ System.out.println("Har is NULL"); } FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har"); har.writeTo(fos); HarLog log = har.getLog(); if(log==null){ System.out.println("Harlog is null"); } List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries()); System.out.println("entries"+entries); for (HarEntry entry : entries){ System.out.println("entry="+entry.getRequest().getUrl()); } File harFile = new File(HAR_FILE_PATH+"2"+".har"); File("/Users/yourpath/"+"2"+".har"); har.writeTo(harFile);
public HarCapture(Har har) throws IOException { super(har.getLog().getPages().get(0).getTitle(), false, new ArrayList<>()); harFile = har; File harFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), HAR_FILE_NAME).toFile(); har.writeTo(harFile); logger.info("HAR capture file copied to " + harFile.getAbsolutePath()); }
// create a new har with given label public void setHar(String label) { server.newHar(label); } public void getHar() throws IOException { // FIXME : What should be done with the this data? Har har = server.getHar(); if (har == null) return; File harFile = new File("C:\\localdev\\bla.har"); har.writeTo(harFile); for (HarEntry entry : har.getLog().getEntries()) { // Check for any 4XX and 5XX HTTP status codes if ((String.valueOf(entry.getResponse().getStatus()).startsWith("4")) || (String.valueOf(entry.getResponse().getStatus()).startsWith("5"))) { log.warn(String.format("%s %d %s", entry.getRequest().getUrl(), entry.getResponse().getStatus(), entry.getResponse().getStatusText())); //throw new UnsupportedOperationException("Not implemented"); } } }