Skip to content

Feat: Added a copy to clipboard feature for copying the test id.#977

Open
Ambuj03 wants to merge 3 commits intopytest-dev:masterfrom
Ambuj03:add-copy-test-id-button
Open

Feat: Added a copy to clipboard feature for copying the test id.#977
Ambuj03 wants to merge 3 commits intopytest-dev:masterfrom
Ambuj03:add-copy-test-id-button

Conversation

@Ambuj03
Copy link
Copy Markdown

@Ambuj03 Ambuj03 commented Nov 23, 2025

As I suggested in discussions #976.
I have tried to add this little feature, Please give the feedback.
Will be happy to make any required changes.

Comment thread src/pytest_html/basereport.py Outdated
data-test-id="{test_id}"
title="Copy test ID"
aria-label="Copy test ID">
<svg xmlns="http://www.w3.org/2000/svg"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how feasible is it to use U+1F4CB instead of the svg - i'd much prefer the character - but i have no idea how well supported that is

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this unicode is better supported across all the browsers and mobile. Updated the PR with this change.
Sample_CopytoClipboard

@Ambuj03 Ambuj03 changed the title Feat: Added a copy to clipboard features for copying the test id. Feat: Added a copy to clipboard feature for copying the test id. Dec 2, 2025
Copilot AI review requested due to automatic review settings May 6, 2026 10:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a “copy test id to clipboard” affordance to the pytest-html results table, allowing users to quickly copy a test’s nodeid from the report UI.

Changes:

  • Adds a copy button next to the rendered test id in the results table HTML.
  • Binds a click handler in the report JS to copy the test id to the clipboard and apply a brief “copied” visual state.
  • Adds styling for the new copy button in both the generated CSS and the SCSS source.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/pytest_html/scripts/main.js Attaches click handling for the new copy button and implements clipboard write behavior.
src/pytest_html/resources/style.css Adds button styling for the copy-to-clipboard UI in the shipped CSS.
src/pytest_html/basereport.py Emits the new copy button markup in the “Test ID” results table cell.
src/layout/css/style.scss Adds button styling in the SCSS source (presumably compiled into the shipped CSS).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pytest_html/scripts/main.js Outdated
Comment thread src/pytest_html/scripts/main.js Outdated
Comment thread src/pytest_html/basereport.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants