Closed VietND96 closed 1 week ago
β±οΈ Estimated effort to review [1-5] | 2 |
π§ͺ Relevant tests | No |
π Security concerns | No |
β‘ Key issues to review |
Possible Bug: The method getVideoFileName is used to fetch both se:videoName and se:name capabilities. However, the method name suggests it is specifically for getting video file names. Consider renaming the method to reflect its generalized use, such as getCapabilityAsString . |
Code Duplication: The logic for sanitizing the name string is duplicated in the getVideoFileName method. Consider extracting this logic into a separate method to improve code maintainability and reduce duplication. |
Category | Suggestion | Score |
Enhancement |
Combine the
___
**Combine the two | 8 |
Possible bug |
Add a null check for
___
**Add a null check for | 7 |
Maintainability |
Use a constant for the video file extension to improve maintainability___ **Use a constant for the video file extension to avoid hardcoding the ".mp4" string multipletimes, which improves maintainability.** [java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java [379-383]](https://github.com/SeleniumHQ/selenium/pull/14148/files#diff-a05d31304c9c75c40d9d11ef388a2c669f1f8c35e943ed8dcbc32e1da7694c5eR379-R383) ```diff -envVars.put("SE_VIDEO_FILE_NAME", String.format("%s.mp4", videoName.get())); -testName.ifPresent(name -> envVars.put("SE_VIDEO_FILE_NAME", String.format("%s.mp4", name))); +final String VIDEO_FILE_EXTENSION = ".mp4"; +envVars.put("SE_VIDEO_FILE_NAME", String.format("%s" + VIDEO_FILE_EXTENSION, videoName.get())); +testName.ifPresent(name -> envVars.put("SE_VIDEO_FILE_NAME", String.format("%s" + VIDEO_FILE_EXTENSION, name))); ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 6Why: Using a constant for repeated string literals like file extensions can improve maintainability and make future changes easier. This suggestion is valid and applicable to the new code in the PR. | 6 |
User description
Thanks for contributing to Selenium! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines. Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Motivation and Context
This is an improvement of https://github.com/SeleniumHQ/selenium/pull/13907
In dynamic grid, whenever capability
se:name
(which shows a test name instead of the session ID in the Grid UI) is set via binding, it is also used to set the output video record file name.To solve a requirement is
Capability
se:videoName
will be used to set video record file name independently. If the capabilityse:videoName
is not set, these:name
is still being used to set for the video record (without regression broken in part of #13907).For example:
After a test is executed, under
/assets
you can see the video file name under/<sessionId>/video.mp4
Types of changes
Checklist
PR Type
enhancement
Description
se:videoName
capability.se:videoName
is not set, the existingse:name
capability will be used as a fallback to name the video file.Changes walkthrough π
DockerSessionFactory.java
Support independent video file naming via `se:videoName` capability.
java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java
se:videoName
capability.
se:name
capability ifse:videoName
is not provided.file naming.