Commit d5a12d8
authored
chore(selenium): patch selenium in v3 pytest plugin for browser test tags (#16531)
## Description
The v3 pytest plugin (`ddtrace.testing.internal.pytest`) does not call `_patch_all()` by default, so the Selenium integration was never applied — browser tests were missing `test.is_browser`, `test.browser.*` tags.
This PR explicitly patches Selenium in `pytest_sessionstart` when the ddtrace trace filter is active (which is the default for the v3 plugin), ensuring browser test visibility tags are set even without `--ddtrace-patch-all`.
## Changes
- **`ddtrace/testing/internal/pytest/plugin.py`**: Patch Selenium in `pytest_sessionstart` when `enable_ddtrace_trace_filter` is true but `enable_all_ddtrace_integrations` is false.
- **`ddtrace/contrib/internal/selenium/patch.py`**: Added docstring explaining how the integration works with both v2 and v3 plugins.
- **`tests/contrib/selenium/test_selenium_chrome.py`**: Added `test_selenium_v3_plugin_tags` to verify browser tags are set with the v3 plugin. Existing snapshot tests are pinned to the old plugin (`DD_PYTEST_USE_NEW_PLUGIN=false`) since they rely on agent traces.
## Testing
- New test `test_selenium_v3_plugin_tags` uses `pytester` with a mocked `WebDriver` to verify `test.is_browser`, `test.browser.name`, and `test.browser.version` tags are correctly set.
## Risks
None — the Selenium patch is wrapped in a try/except and only applies in the v3 plugin path.
Co-authored-by: federico.mon <federico.mon@datadoghq.com>1 parent 4d6a8ee commit d5a12d8
2 files changed
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
323 | 332 | | |
324 | 333 | | |
325 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| 175 | + | |
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
| |||
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| 231 | + | |
228 | 232 | | |
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments