[google-chrome] WebDriverException : 알 수없는 오류 : Chrome 브라우저를 시작하는 동안 DevToolsActivePort 파일이 없습니다

URL로 크롬을 시작하려고하면 브라우저가 시작되고 그 후에는 아무것도하지 않습니다.

1 분 후에 아래 오류가 표시됩니다.

Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)

내 구성 :

  • 크롬 : 66
  • 크롬 브라우저 : 2.39.56

PS 는 Firefox에서 잘 작동합니다.



답변

이 오류 메시지는 …

org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist

크롬 드라이버 가 새로운 웹 브라우저 ( 예 : 크롬 브라우저 세션) 를 시작하거나 생성 할 수 없음을 의미합니다 .

코드 시험판과 모든 바이너리의 버전 정보는 무엇이 잘못되었는지에 대한 힌트를 주었을 것입니다.

그러나 기본 실행 플래그 에 대한 Add –disable-dev-shm-usage에 따르면 인수 --disable-dev-shm-usage를 추가 하면 일시적으로 문제가 해결되는 것으로 보입니다 .

Chrome 브라우저 세션 을 시작 / 스팬 하려면 다음 솔루션을 사용할 수 있습니다.

System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized"); // open Browser in maximized mode
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"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
WebDriver driver = new ChromeDriver(options);
driver.get("https://google.com");

disable-dev-shm-usage

당으로 base_switches.cc disable-dev-shm-usage 에서만 유효한 것으로 보인다 리눅스 OS :

#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// The /dev/shm partition is too small in certain VM environments, causing
// Chrome to fail or crash (see http://crbug.com/715363). Use this flag to
// work-around this issue (a temporary directory will always be used to create
// anonymous shared memory files).
const char kDisableDevShmUsage[] = "disable-dev-shm-usage";
#endif

토론 에서 / dev / shm 대신 / tmp를 사용하는 옵션 추가 David는 다음과 같이 언급합니다.

/ dev / shm 및 / tmp가 어떻게 마운트되는지에 달려 있다고 생각합니다. 둘 다 tmpfs로 마운트되면 아무런 차이가 없다고 가정합니다. 어떤 이유로 / tmp가 tmpfs로 매핑되지 않은 경우 (기본적으로 systemd에서 기본적으로 tmpfs로 매핑 된 것으로 생각됨) Chrome 공유 메모리 관리는 익명의 공유 파일을 만들 때 항상 파일을 메모리에 매핑하므로이 경우에도 많은 차이가 있습니다. 플래그를 사용하여 원격 측정 테스트를 강제로 수행하고 어떻게 진행되는지 볼 수 있습니다.

기본적으로 사용하지 않는 이유는 공유 메모리 팀에 의해 밀려 난 것입니다. 기본적으로 공유 메모리에 / dev / shm을 사용해야한다는 것이 합리적이라고 생각합니다.

궁극적 으로이 모든 것이 memfd_create를 사용하도록 옮겨야하지만 Chrome 메모리 관리를 크게 리팩토링해야하기 때문에 곧 일어날 것이라고 생각하지 않습니다.


아우트로

다음은 샌드 박스 스토리에 대한 링크 입니다.


답변

나는 2018-06-04 월요일 에이 문제를보기 시작했습니다. 우리의 테스트는 매주 실행됩니다. 변경된 것은 구글 크롬 버전 (현재로 업데이트 된) JVM과 Selenium이 Linux 상자의 최신 버전 (Java 1.8.0_151, selenium 3.12.0, google-chrome 67.0.3396.62) 인 것으로 보입니다. xvfb-run).
특히 ” –no-sandbox “및 ” –disable-dev-shm-usage ” 인수를 추가 하면 오류가 중지되었습니다. 이 문제를 조사하여 효과에 대한 자세한 정보와 Google 크롬을 업데이트 한 원인에 대한 기타 질문을 찾아 보겠습니다.

ChromeOptions options = new ChromeOptions();
        ...
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-dev-shm-usage");


답변

우리는 젠킨스 슬레이브 (리눅스 머신)에서 동일한 문제를 겪고 있었고 위의 모든 옵션을 시도했습니다.

유일한 도움은 논쟁을 설정하는 것입니다

chrome_options.add_argument('--headless')

그러나 우리가 더 조사했을 때 XVFB 화면이 속성을 시작하지 않아서이 오류를 일으키는 것으로 나타났습니다. XVFB 화면을 수정 한 후 문제가 해결되었습니다.


답변

파이썬에서도 같은 문제가있었습니다. 위의 도움이되었습니다. 다음은 파이썬에서 사용한 것입니다.

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('/path/to/your_chrome_driver_dir/chromedriver',chrome_options=chrome_options)


답변

최신 정보:

문제를 해결할 수 있으며 원하는 URL로 크롬에 액세스 할 수 있습니다.

제공된 솔루션을 시도한 결과 :

위에 제공된 모든 설정을 시도했지만 문제를 해결할 수 없습니다

문제에 대한 설명 :

내 관찰에 따르면 DevToolsActivePort 파일이 존재하지 않습니다 .chrome이 scoped_dirXXXXX 폴더에서 해당 참조를 찾을 수 없을 때 발생합니다.

문제를 해결하기 위해 취한 단계

  1. 모든 크롬 프로세스와 크롬 드라이버 프로세스를 종료했습니다.
  2. 크롬을 호출하기 위해 아래 코드를 추가했습니다.

    System.setProperty("webdriver.chrome.driver","pathto\\chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("useAutomationExtension", false);
    WebDriver driver = new ChromeDriver(options);
    driver.get(url);
    

위의 단계를 사용하여 문제를 해결할 수있었습니다.

답변 주셔서 감사합니다.


답변

나는 최근에 같은 문제에 직면했으며 시행 착오 후에 나에게도 효과가있었습니다.

정상에 있어야합니다 :

options.addArguments("--no-sandbox"); //has to be the very first option

BaseSeleniumTests.java

public abstract class BaseSeleniumTests {

    private static final String CHROMEDRIVER_EXE = "chromedriver.exe";
    private static final String IEDRIVER_EXE = "IEDriverServer.exe";
    private static final String FFDRIVER_EXE = "geckodriver.exe";
    protected WebDriver driver;

    @Before
    public void setUp() {
        loadChromeDriver();
    }

    @After
    public void tearDown() {
        if (driver != null) {
            driver.close();
            driver.quit();
        }
    }

    private void loadChromeDriver() {
        ClassLoader classLoader = getClass().getClassLoader();
        String filePath = classLoader.getResource(CHROMEDRIVER_EXE).getFile();
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeDriverService service = new ChromeDriverService.Builder()
                .usingDriverExecutable(new File(filePath))
                .build();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--no-sandbox"); // Bypass OS security model, MUST BE THE VERY FIRST OPTION
        options.addArguments("--headless");
        options.setExperimentalOption("useAutomationExtension", false);
        options.addArguments("start-maximized"); // open Browser in maximized mode
        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"); // overcome limited resource problems
        options.merge(capabilities);
        this.driver = new ChromeDriver(service, options);
    }

}

GoogleSearchPageTraditionalSeleniumTests.java

@RunWith(SpringRunner.class)
@SpringBootTest
public class GoogleSearchPageTraditionalSeleniumTests extends BaseSeleniumTests {

    @Test
    public void getSearchPage() {
        this.driver.get("https://www.google.com");
        WebElement element = this.driver.findElement(By.name("q"));
        assertNotNull(element);
    }

}

pom.xml

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
        </dependency>
</dependencies>


답변

제 경우에는 다음 환경에서 :

  • 윈도우 10
  • 파이썬 3.7.5
  • 경로에있는 Chrome 버전 80 및 해당 ChromeDriver C:\Windows
  • 셀렌 3.141.0

나는 인수를 추가 할 필요 --no-sandbox--remote-debugging-port=9222받는 ChromeOptions객체 관리자로 파워 쉘 / cmd를 점심으로 관리자 사용자로 코드를 실행합니다.

관련 코드는 다음과 같습니다.

options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('--disable-infobars')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
options.add_argument('--remote-debugging-port=9222')
driver = webdriver.Chrome(options=options)