3

I'm trying to make selenium take the information that is in the console for my IDE and to save it as a dynamic file instead of it being overwritten.

This is currently what I use to find the console log which works well.

 LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
 for (LogEntry entry : logEntries) {
 System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());

My IDE then saves the output to a file. However, I was wondering if there was some way to just take the information from the console into a new file each time? I've done this with screenshots, but not too sure about the console.

asked Nov 28, 2016 at 20:48

1 Answer 1

3

One thing that could facilitate an answer is to know what is your IDE and if you can configure this behavior of saving in a file.

Considering you can programmatically set configurations of the name of this output file, to make it unique, you could append the time since epoch to its base name.

In Python:

import time
sec_epoch = int(time.time())

In Java:

Date.getTime()

If you can not configure the output file name, you could execute your commands from the terminal and save the content to a file using redirection.

answered Nov 28, 2016 at 21:37
1
  • Your comment actually worked and made me have another idea where I could just add "-${current_date}.txt" into the output file name which makes it dynamic now. Commented Nov 28, 2016 at 22:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.