You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Jenkins中禁用无头模式运行WiniumDriver自动化测试

How to Disable WiniumDriver Headless Mode in Jenkins

Hey there, let's work through getting your WiniumDriver tests running without headless mode in Jenkins. I’ve tackled similar desktop automation hiccups before, so here’s a straightforward breakdown:

1. Adjust Your Test Code Configuration

First, check if your test code explicitly enables headless mode. Winium uses driver options to control this setting—you’ll want to either remove the headless flag or set it to false:

Example (C#):

var winiumOptions = new WiniumDesktopOptions();
// Either remove this line entirely, or set it to false
winiumOptions.Headless = false; 
// Initialize driver with updated options
var driver = new WiniumDriver(@"C:\path\to\winiumdriver.exe", winiumOptions);

Example (Java):

WiniumDesktopOptions options = new WiniumDesktopOptions();
// Disable headless mode explicitly
options.setHeadless(false);
WiniumDriver driver = new WiniumDriver(new URL("http://localhost:9999"), options);

2. Update Jenkins Build Parameters/Commands

If headless mode is being triggered via Jenkins build settings:

  • Check build parameters: If you’ve set a parameter like HEADLESS_MODE to true in your Jenkins job, edit the job and change its value to false.
  • Modify execution commands: If your build step runs a command that launches WiniumDriver with the --headless flag (e.g., winiumdriver.exe --headless), remove that flag entirely so the command becomes just winiumdriver.exe.

3. Ensure Jenkins Has Access to a Desktop Session

A common gotcha: Jenkins running as a Windows service might not have access to an active desktop session, even with headless mode disabled. To fix this:

  • Open Windows Services, find the Jenkins service, go to the Log On tab.
  • Check the box that says "Allow service to interact with desktop".
  • Restart the Jenkins service.
  • Alternatively, run Jenkins directly from a user session (not as a service) by executing java -jar jenkins.war in a command prompt while logged into the machine. This ensures the driver can launch visible windows.

4. Validate the Fix

After making these changes, trigger a new Jenkins build. Check the build logs for any errors, and verify that the WiniumDriver launches the target application in a visible window (you might need remote desktop access to the Jenkins machine to confirm this).

内容的提问来源于stack exchange,提问作者CelsoRicardo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:49:55