selenium-standalone
selenium-standalone copied to clipboard
[🐛 Bug]: Selenium does not "frees" the port
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
WebdriverIO Version
7.16.6
Node.js Version
v16.13.0
Mode
WDIO Testrunner
Which capabilities are you using?
No response
What happened?
I am able to run the test on the first time. However, on the next runs, I got the error:
ERROR @wdio/selenium-standalone-service: Error: Port 4444 is already in use.
To "free" the port I need to manually kill the process running in the Windows command prompt:
netstat -aof | findstr :4444
taskkill /PID
What is your expected behavior?
After the run, selenium stops and "frees" the ports.
How to reproduce the bug.
Run a project with the following settings:
-
java version "17.0.1" 2021-10-19 LTS
-
package.json:
{ "name": "name", "version": "1.0.0", "description": "description", "scripts": { "build": "tsc", "test": "wdio wdio.conf.ts" }, "dependencies": { "@cucumber/cucumber": "^7.3.1", "@types/chai": "^4.2.22", "@types/node": "^16.11.11", "@wdio/cli": "7.16.6", "@wdio/cucumber-framework": "7.16.6", "@wdio/local-runner": "7.16.6", "@wdio/selenium-standalone-service": "7.16.6", "chai": "4.3.4", "multiple-cucumber-html-reporter": "1.18.0", "ts-node": "10.4.0", "tsconfig-paths": "3.12.0", "typescript": "4.5.2", "wdio-cucumberjs-json-reporter": "3.0.0", "webdriverio": "7.16.6" } }
- wdio.conf.ts:
`{ runner: "local", specs: ["./src/features//*.feature"], exclude: [], maxInstances: 1, capabilities: [ { browserName: "chrome", 'goog:chromeOptions': { args: [ '--disable-infobars', '--start-maximized' ] }, }, ], logLevel: "warn", bail: 0, baseUrl: "https://www.google.com", waitforTimeout: 20000, connectionRetryTimeout: 60000, connectionRetryCount: 3, services: [ [ "selenium-standalone" ], ], framework: "cucumber", reporters: [ [ "cucumberjs-json", { jsonFolder: "reports/cucumberjs/", }, ], ], cucumberOpts: { requireModule: ["tsconfig-paths/register"], require: ["./src/steps//*.ts"], backtrace: true, dryRun: false, failFast: false, format: ["pretty"], colors: true, snippets: false, source: false, profile: [], strict: true, tagExpression: "", timeout: 60000, ignoreUndefinedDefinitions: false, }, autoCompileOpts: { autoCompile: true,
tsNodeOpts: {
transpileOnly: false,
project: "tsconfig.json",
files: true,
},
},
...hooks,
}; `
Relevant log output
ERROR @wdio/selenium-standalone-service: Error: Port 4444 is already in use.
at Object.start (C:\Repos\temp\ui\e2e\node_modules\selenium-standalone\lib\start.js:117:11)
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- [X] I have searched the existing issues
Thanks for reporting!
I think we can definitely do something here to ensure the port gets open up again.
Any contributions that resolves the bug are highly appreciated. Please take a look into our contribution guidelines and let us know if you have any questions. Cheers!
Unfortunately, I faced the same issue :(
Windows 11 Home, version: 21H2 OS build 22000.556 Windows Feature Experience Pack 1000.22000.556.0
Node: v16.14.2 @wdio/cli: ^7.19.3 @wdio/selenium-standalone-service: ^7.19.1
I am also seeing this same issue
Windows 10 Node 14.7.0 @wdio/cli 7.16.15 @wdio/selenium-standalone-service 7.16.14 JDK 1.8
Thanks @alexstep-dev and @Nicolas-Moore for verifying that this bug exist. Anyone has some free cycles to work on fixing it?
Hi. Have the same issue:
Windows 10 Node 16.14.0 @wdio/cli 7.19.5 @wdio/selenium-standalone-service 7.19.5
I haven't seen this issue surface on Mac or Linux, just Windows.
But closing and re-opening the Command Line kills the Selenium session for now.
I had this similar issue on my windows 11. I uninstall Java JDK 18 that I had originally installed and re-install openJDK 17 winget install Microsoft.OpenJDK.17
and now this is no longer an issue. @joaodanielopes @Lara2409 @PFaz540 do you want to give a try and see if this resolves the issue?
Hi @christian-bromann , I am still getting the same error. When I am trying to execute the same test again it says -
I am using - Window machine 10 JDK - 18 node - 18.0.0 @wdio/cli - 7.26.0 @wdio/selenium-standalone-service - 7.26.0
Could you please confirm for me if this issue is still open or closed?
Could you please confirm for me if this issue is still open or closed?
As you can see this issue is still open.
To me it was JAVA path issue. I used following steps to fix this problem: Go to System Properties > Environment Variables
- On environmental variables (windows), verify the system variable path for java is correct. e.g
C:\Program Files\Microsoft\jdk-17.0.4.101-hotspot\bin
- If you have multiple path, moved java home path to the top on env variable list.
- Verify the JAVA_HOME path is correct. e.g
C:\Program Files\Microsoft\jdk-17.0.4.101-hotspot\
I had to restart the machine once I made this changes.
In a way to prevent the behavior here is new feature https://github.com/webdriverio/selenium-standalone/pull/838
it has been resolved in https://github.com/webdriverio/selenium-standalone/pull/838