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

Spring Boot集成Selenium无法自动启动浏览器问题求助

Spring Boot集成Selenium无法启动浏览器问题排查

在Spring Boot项目中集成Selenium时遇到问题:Selenium无法自动启动浏览器,运行其他示例代码也无效。这是首次使用Spring Boot,即便复制了已验证的成功示例,问题依旧存在。已查阅相关解决方案,但程序仍无法正常运行,恳请提供帮助。

相关代码

package com.ptuproject.ptuproject.Controller;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Component
public class SeleniumController {
    private WebDriver driver;

    public void process() {
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");

        driver = new ChromeDriver();

        driver.get("https://www.google.co.kr/");

    }

}

build.gradle依赖配置

dependencies {
    implementation 'org.seleniumhq.selenium:selenium-java:4.1.2'
}

程序运行输出截图

程序运行输出截图

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 08:27:50