我需要录制网页上可用视频的音频。 并希望将其保存在
中.MP3
格式。
任何人都知道如何实现它。是否需要添加外部罐来实现此结果?
答案 0 :(得分:1)
您需要使用第三方软件包AtuTestRecorder。
@BeforeTest public void setup() throws Exception { DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH-mm-ss"); Date date = new Date(); //Created object of ATUTestRecorder //Provide path to store videos and file name format. recorder = new ATUTestRecorder("E:\ScriptVideos\","TestVideo-"+dateFormat.format(date),false); //To start video recording. recorder.start(); driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://google.com/"); }@AfterTest public void Close() throws Exception { driver.quit(); recorder.stop(); //To stop video recording. }
答案 1 :(得分:0)
您可以在Oracle website上找到有关此内容的文档。但这是您需要的代码:
TargetDataLine line;
DataLine.Info info = new DataLine.Info(TargetDataLine.class,
format); // format is an AudioFormat object
if (!AudioSystem.isLineSupported(info)) {
// Handle the error ...
}
// Obtain and open the line.
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
} catch (LineUnavailableException ex) {
// Handle the error ...
}
答案 2 :(得分:-1)
Selenium旁边需要一种编程语言。 Selenium只能检查音频是否正在播放但无法录制音频。
我知道Java和C#可以录制音频并以.Mp3格式保存。