求知 文章 文库 Lib 视频 iPerson 课程 认证 咨询 工具 讲座 Model Center   模型库  
会员   
 


基于 UML 和EA进行分析设计
7月30-31日 北京+线上



大模型核心技术RAG、MCP与智能体实践
8月14-15日 厦门



图数据库与知识图谱
8月23日-24日 北京+线上
 
 
  Selenium鏁欑▼
Selenium姒傝堪
Selenium IDE
Selenium IDE涓嬭浇
Selenium IDE 宸ュ叿鐗圭偣
Selenium IDE娴嬭瘯鍒涘缓
Selenium IDE娴嬭瘯
Selenium IDE楠岃瘉鐐
Selenium - IDE妯″紡鍖归厤
Selenium鐢ㄦ埛鎵╁睍
Selenium IDE- 涓嶅悓鐨勬祻瑙堝櫒
Selenium 鐜瀹夎璁剧疆
Selenium RC
Selenium - Selenese鍛戒护
Selenium Webdriver
Selenium瀹氫綅鍣
鏂囨湰妗嗙殑鐩镐簰浣滅敤
鍗曢夋寜閽簰鍔
澶嶉夋浜や簰
涓嬫媺妗嗕氦浜
Synchronization 鍚屾
鎷栨斁
閿洏鎿嶄綔
榧犳爣鎿嶄綔
澶氶夋嫨鎿嶄綔
鏌ユ壘鎵鏈夐摼鎺
Selenium娴嬭瘯璁捐鎶鏈
Selenium椤甸潰瀵硅薄妯″瀷
浣跨敤Excel鏁版嵁椹卞姩
log4j鏃ュ織
寮傚父澶勭悊
澶氭祻瑙堝櫒娴嬭瘯
鎹曟崏灞忓箷鎴浘
鎹曟崏瑙嗛
Selenium TestNG
Selenium缃戞牸
 
 

捕捉视频
1184 次浏览
5次  

捕捉视频

有时候我们未必能够分析故障只需用日志文件或截图的帮助。有时捕获完整的执行视频帮助。让我们了解如何捕捉视频。

我们将利用Monte媒体库的执行相同。

配置

第1步:导航到URL - http://www.randelshofer.ch/monte/index.htmll和下载屏幕记录JAR,如下图所示。

第2步:下载后,添加JAR文件添加到当前项目的库。

第3步:我们会利用Java的AWT包来初始化显卡配置。

GraphicsConfiguration gc = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();

第4步:它采用下列参数创建ScreenRecorder的一个实例。

示例

我们将捕获简单的测试执行视频 - 百分比计算。

import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.monte.media.math.Rational;
import org.monte.media.Format;
import org.monte.screenrecorder.ScreenRecorder;
import static org.monte.media.AudioFormatKeys.*;
import static org.monte.media.VideoFormatKeys.*;
import java.awt.*;

public class webdriverdemo
{
private static ScreenRecorder screenRecorder;
public static void main(String[] args) throws IOException, AWTException
{
GraphicsConfiguration gconfig = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();

screenRecorder = new ScreenRecorder(gconfig,
new Format(MediaTypeKey, MediaType.FILE,
MimeTypeKey, MIME_AVI),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey,
ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
DepthKey, (int)24, FrameRateKey, Rational.valueOf(15),
QualityKey, 1.0f,
KeyFrameIntervalKey, (int) (15 * 60)),
new Format(MediaTypeKey, MediaType.VIDEO,
EncodingKey,"black",
FrameRateKey, Rational.valueOf(30)), null);

WebDriver driver = new FirefoxDriver();

// Start Capturing the Video
screenRecorder.start();

//Puts a Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

//Launch website
driver.navigate().to("http://www.calculator.net/");

//Maximize the browser
driver.manage().window().maximize();

// Click on Math Calculators
driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click();

// Click on Percent Calculators
driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click();

// Enter value 10 in the first number of the percent Calculator
driver.findElement(By.id("cpar1")).sendKeys("10");

// Enter value 50 in the second number of the percent Calculator
driver.findElement(By.id("cpar2")).sendKeys("50");

// Click Calculate Button
driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click();

// Get the Result Text based on its xpath
String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText();

File screenshot = ((TakesScreenshot)driver).getScreenshotAs
(OutputType.FILE);

FileUtils.copyFile(screenshot, new File("D:screenshotsscreenshots1.jpg"));

//Print a Log In message to the screen
System.out.println(" The Result is " + result);

//Close the Browser.
driver.close();

// Stop the ScreenRecorder
screenRecorder.stop();
}
}

输出

录制的视频保存在“C:users<<UserName>>Videos”文件夹,如下图所示。


您可以捐助,支持我们的公益事业。

1元 10元 50元





认证码: 验证码,看不清楚?请点击刷新验证码 必填



1184 次浏览
5次
 捐助