java调用webdriver时会报错Exception in thread "main" org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to ,只需要加上--remote-allow-origins=*参数就可以解决

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.2.1</version>
        </dependency>

import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

public class test {
    public static void main(String[] args) throws Exception {
        //设置驱动路径
        System.setProperty("webdriver.chrome.driver", "F:\\JAVA\\chromedriver_win32\\chromedriver.exe");
        System.setProperty("webdriver.gecko.driver", "F:\\JAVA\\geckodriver-v0.34.0-win32\\geckodriver.exe");
        System.setProperty("webdriver.edge.driver", "F:\\JAVA\\edgedriver_win64\\msedgedriver.exe");
        //定义driver
        EdgeOptions options = new EdgeOptions();
        //添加参数解决报错问题
        options.addArguments("--remote-allow-origins=*");
        EdgeDriver driver = new EdgeDriver(options);
        // 最大化浏览器窗口
        driver.manage().window().maximize();
        // 访问百度首页
        driver.get("http://www.baidu.com");
        Thread.sleep(2000);
        //打开下载管理
        driver.get("edge://downloads/all");
        // 关闭浏览器
        Thread.sleep(10000);
        driver.quit();
    }
}