MS Edge driver error: DevToolsActivePort file doesn't exist , works only with --headless

MS Edge driver error: DevToolsActivePort file doesn't exist , works only with --headless

MSEdgeDriver 和浏览器版本使用 88.0.705.63(64 位)。

在提供边缘时工作 options.addArguments("--headless"); 但是当它被删除时不起作用。抛出以下错误

Message: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'A036T0L6347NRVX', ip: '10.227.221.75', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_66'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
    Ordinal0 [0x00007FF6D6D0AF92+241554]
    GetHandleVerifier [0x00007FF6D747CA88+2173368]
    GetHandleVerifier [0x00007FF6D749FAC8+2316792]
    GetHandleVerifier [0x00007FF6D7499BC9+2292473]
    GetHandleVerifier [0x00007FF6D74CB760+2496144]
    GetHandleVerifier [0x00007FF6D74C7A5F+2480527]
    GetHandleVerifier [0x00007FF6D74A550A+2339898]
    GetHandleVerifier [0x00007FF6D74A614B+2343035]
    Ordinal0 [0x00007FF6D6CE2D01+77057]

使用的边缘选项:

EdgeOptions options = new EdgeOptions();
        options.addArguments("--no-sandbox");
        options.setBinary("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
        options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
        options.addArguments("disable-infobars"); // disabling infobars
        options.addArguments("--disable-extensions"); // disabling extensions
        options.addArguments("--disable-gpu"); // applicable to windows os only
        options.addArguments("--disable-dev-shm-usage");

我搜索了很多,发现有很多类似的问题:, 。您也可以尝试另一种解决方法:添加 --remote-debugging-port=<port>.

关于问题的原因,我觉得this answer有道理。您也可以尝试答案中的其他解决方案。