Skip to content

fix(@wdio/reporter): propagate failing session creation to report#14223

Merged
christian-bromann merged 2 commits intomainfrom
cb/no-session-error
Feb 24, 2025
Merged

fix(@wdio/reporter): propagate failing session creation to report#14223
christian-bromann merged 2 commits intomainfrom
cb/no-session-error

Conversation

@christian-bromann
Copy link
Member

Proposed changes

Right now WebdriverIO doesn't do a good job in propagating a session creation error to the reports. This patch fixes that:

 "spec" Reporter:
------------------------------------------------------------------
[chrome Windows 11 #0-0] Running: chrome on Windows 11
[chrome Windows 11 #0-0]
[chrome Windows 11 #0-0] ✖ Failed to create a session:
[chrome Windows 11 #0-0] WebDriverError: session not created: No matching capabilities found when running "http://localhost:61256/session" with method "POST" and args "{"capabilities":{"alwaysMatch":{"browserName":"chrome","platformName":"Windows 11","goog:chromeOptions":{"binary":"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"},"webSocketUrl":true,"unhandledPromptBehavior":"ignore"},"firstMatch":[{}]}}"
[chrome Windows 11 #0-0]


 "junit" Reporter:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" errors="0" skipped="0">
  <testcase>
    <failure message="WebDriverError: session not created: No matching capabilities found when running &quot;http://localhost:61256/session&quot; with method &quot;POST&quot; and args &quot;{&quot;capabilities&quot;:{&quot;alwaysMatch&quot;:{&quot;browserName&quot;:&quot;chrome&quot;,&quot;platformName&quot;:&quot;Windows 11&quot;,&quot;goog:chromeOptions&quot;:{&quot;binary&quot;:&quot;/Applications/Google Chrome.app/Contents/MacOS/Google Chrome&quot;},&quot;webSocketUrl&quot;:true,&quot;unhandledPromptBehavior&quot;:&quot;ignore&quot;},&quot;firstMatch&quot;:[{}]}}&quot;"/>
  </testcase>
</testsuites>

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Feb 24, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 24, 2025

Open in Stackblitz

eslint-plugin-wdio

npm i https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@14223

@wdio/allure-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@14223

@wdio/browser-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@14223

@wdio/appium-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@14223

@wdio/browserstack-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@14223

@wdio/cli

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@14223

@wdio/concise-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@14223

@wdio/config

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@14223

@wdio/cucumber-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@14223

@wdio/dot-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@14223

@wdio/firefox-profile-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@14223

@wdio/globals

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@14223

@wdio/jasmine-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@14223

@wdio/json-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@14223

@wdio/junit-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@14223

@wdio/lighthouse-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@14223

@wdio/local-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@14223

@wdio/logger

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@14223

@wdio/mocha-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@14223

@wdio/protocols

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@14223

@wdio/repl

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@14223

@wdio/reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@14223

@wdio/runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@14223

@wdio/sauce-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@14223

@wdio/shared-store-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@14223

@wdio/smoke-test-cjs-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@14223

@wdio/smoke-test-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@14223

@wdio/smoke-test-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@14223

@wdio/spec-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@14223

@wdio/static-server-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@14223

@wdio/sumologic-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@14223

@wdio/testingbot-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@14223

@wdio/types

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@14223

@wdio/utils

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@14223

@wdio/webdriver-mock-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@14223

webdriver

npm i https://pkg.pr.new/webdriverio/webdriverio/webdriver@14223

webdriverio

npm i https://pkg.pr.new/webdriverio/webdriverio@14223

commit: b09244a

@christian-bromann christian-bromann merged commit 10fe027 into main Feb 24, 2025
46 checks passed
@christian-bromann christian-bromann deleted the cb/no-session-error branch February 24, 2025 18:50
@therealbrad
Copy link
Contributor

@christian-bromann This change broke our Jenkins JUnit reporting.

I filter test executions using mocha-opts.grep which leaves me with a lot of (expected) sessions with no tests and empty junit xml files. They used to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" errors="0" skipped="0"/>

But now they look like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" errors="0" skipped="0">
  <testcase>
    <failure message="No tests found"/>
  </testcase>
</testsuites>

The JUnit Reporter plugin for Jenkins throws this error on the new files:

ERROR: Step 'Publish JUnit test result report' aborted due to exception: 
java.lang.NullPointerException
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.<init>(CaseResult.java:211)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:487)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:401)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:369)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:604)
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to Real Device
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1923)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:384)
		at hudson.remoting.Channel.call(Channel.java:1112)
		at hudson.FilePath.act(FilePath.java:1228)
		at hudson.FilePath.act(FilePath.java:1217)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:146)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:177)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:282)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:194)
		at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
		at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
		at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
		at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
		at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
		at hudson.model.Build$BuildExecution.post2(Build.java:179)
		at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
		at hudson.model.Run.execute(Run.java:1854)
		at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
		at hudson.model.ResourceController.execute(ResourceController.java:101)
		at hudson.model.Executor.run(Executor.java:445)
Caused: java.io.IOException: Failed to read /home/bdermanouelian/jenkins_home/workspace/iOS UI Performance/src/ios/reports/results-undefined-undefined-0-0.xml
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:615)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:518)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:454)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:436)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:413)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.<init>(TestResult.java:259)
	at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:238)
	at Jenkins v2.479.2//hudson.FilePath$FileCallableWrapper.call(FilePath.java:3614)
	at hudson.remoting.UserRequest.perform(UserRequest.java:225)
	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
	at hudson.remoting.Request$2.run(Request.java:391)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:81)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
	```
	

@christian-bromann
Copy link
Member Author

@therealbrad thanks for reporting, mind raising a new issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants