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

Selenium封装Jar在SoapUI中调用无法加载HTTPS URL的解决方案求助

Fix for HTTPS URLs Not Loading in SoapUI with Selenium + BrowserMobProxy

Hey there, let's figure out why your HTTPS URLs work smoothly in Eclipse but fail when running the JAR in SoapUI. This issue almost always ties back to SSL certificate handling or environment-specific proxy conflicts. Here are the step-by-step fixes to try:

1. Trust BrowserMobProxy's Root CA Certificate in SoapUI's JVM

BrowserMobProxy uses its own custom CA certificate to intercept and decrypt HTTPS traffic. Eclipse's JVM might automatically trust this certificate, but SoapUI's bundled JRE doesn't. Here's how to fix it:

First, add code to export BMP's CA certificate when your proxy starts:

// Right after proxy.start()
File bmpCert = new File("bmp-root-ca.crt")
proxy.getRootCertificate().saveAsPemFile(bmpCert)
println "BMP CA certificate saved to: " + bmpCert.getAbsolutePath()

Next, import this certificate into SoapUI's JRE keystore (replace [SOAPUI_JRE_PATH] with the actual path to SoapUI's bundled JRE, usually inside your SoapUI installation folder):

keytool -importcert -file bmp-root-ca.crt -alias bmp-ca -keystore [SOAPUI_JRE_PATH]/lib/security/cacerts -storepass changeit

When prompted, type yes to confirm trusting the certificate.

2. Add Chrome-Specific SSL Arguments to DesiredCapabilities

Even with ACCEPT_SSL_CERTS set, Chrome might still block the untrusted certificate. Add these Chrome options to explicitly handle SSL:

// Replace your existing DesiredCapabilities setup with this
DesiredCapabilities capabilities = DesiredCapabilities.chrome()
ChromeOptions chromeOptions = new ChromeOptions()

// Pass the BMP proxy to Chrome
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy)
chromeOptions.setProxy(seleniumProxy)

// Add SSL-related arguments to bypass certificate checks
chromeOptions.addArguments("--ignore-certificate-errors")
chromeOptions.addArguments("--allow-running-insecure-content")
// Optional: Use if testing local HTTPS URLs
chromeOptions.addArguments("--allow-insecure-localhost")

// Merge capabilities and initialize the driver
capabilities.merge(chromeOptions)
WebDriver driver = new ChromeDriver(capabilities)

3. Disable SoapUI's Global Proxy Settings

SoapUI's built-in proxy might conflict with your BrowserMobProxy setup. Turn it off:

  • Open SoapUI → Go to File → Preferences → Proxy
  • Uncheck the Enable proxy checkbox
  • Click Apply and restart SoapUI

4. Ensure ChromeDriver Path is Accessible in SoapUI

When running from a JAR, relative paths can break. Use an absolute path or place chromedriver.exe in SoapUI's bin folder:

// Use absolute path (example for Windows)
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe")

// OR use path relative to SoapUI's working directory
System.setProperty("webdriver.chrome.driver", new File("chromedriver.exe").getAbsolutePath())

5. Debug with HAR Files

Generate a HAR file to see exactly where the HTTPS request fails:

// Start a new HAR session before loading the URL
proxy.newHar("soapui-test-har")

// Load your HTTPS URL
driver.get(URL.toString())

// Save the HAR file after the request completes
Har har = proxy.getHar()
har.writeTo(new File("soapui-test.har"))

Open the HAR file in Chrome DevTools (Network tab → Import HAR) to check for specific errors like certificate warnings or connection timeouts.

Start with the first two fixes—they resolve 90% of HTTPS issues in this scenario. If you still run into problems, the HAR file will give you concrete clues about what's going wrong.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:26:14