You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Selenium Dynamic Grid中自定义录制视频文件名及输出目录名(替代默认video.mp4)

Customizing Video Filename & Output Directory in Selenium Dynamic Grid

Got it, let’s walk through how to get the exact directory structure and filenames you want. Here’s a straightforward breakdown:

1. Replace Session-ID Directory with Custom Scenario Name

By default, Dynamic Grid uses the session ID for the output folder. To override this, you’ll set the se:outputDirectory capability in your test’s desired capabilities. This defines a custom folder path relative to the base assets directory that Dynamic Grid uses.

Example Code Snippets

Java:

ChromeOptions options = new ChromeOptions();
// Set custom directory name
options.setCapability("se:outputDirectory", "succesfullLoginScenario");
// Add other required capabilities (like browser version, etc.)
WebDriver driver = new RemoteWebDriver(new URL("http://your-grid-url:4444"), options);

Python:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.set_capability("se:outputDirectory", "succesfullLoginScenario")
driver = webdriver.Remote(
    command_executor='http://your-grid-url:4444',
    options=chrome_options
)

This will create the assets/succesfullLoginScenario folder instead of the session-ID-named one.

2. Customize the Video Filename

The default video.mp4 can be replaced using the se:videoName capability. Explicitly set your desired filename (including the .mp4 extension to avoid any auto-naming surprises).

Extending the Examples

Java:

// Add this to the options setup
options.setCapability("se:videoName", "succesfullLoginScenario.mp4");

Python:

// Add this to the chrome_options setup
chrome_options.set_capability("se:videoName", "succesfullLoginScenario.mp4")

Final Result

When you combine both capabilities, your test will generate exactly the structure you asked for:

-> assets/succesfullLoginScenario
-> sessionCapabilities.json
-> succesfullLoginScenario.mp4

Quick Tips

  • Ensure your Dynamic Grid nodes have video recording enabled (this is typically configured when starting the node with the video service).
  • For parallel tests, generate unique directory/video names dynamically (e.g., pull the test method name from your framework like TestNG, JUnit, or pytest) to avoid overwriting files.
  • Verify the Grid user has write permissions to the assets directory and custom subfolders.

内容的提问来源于stack exchange,提问作者Necati Özdemir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 03:24:06