1
그래서 크롬 (63)와 현재 멀티 클라이언트 원격 디버깅이 지원됩니다

(https://developers.google.com/web/updates/2017/10/devtools-release-notes)멀티 클라이언트 원격 디버깅

내가 어떤 셀레늄과 크롬 DevTools로 프로토콜 HeapProfiler를 사용한다 달성하고자하는 테스트. 버전 64 Chrome 개발 채널과 ChromeDriver 2.33을 실행하고 있습니다.

ChromeOptions options = newChromeOptions(); 
options.addArguments("--remote-debugging-port=9222"); 
WebDriver driver = new ChromeDriver(options); 
... selenium stuff 

새로운 크롬 창이 열리고 시간이 초과 될 때까지 중단됩니다. 버전을 확인하려면 Google 크롬에 대해 도움을 받으러 Chrome 크롬 창이 열렸 음을 확인할 수 있습니다. webdriver 연결이 끊어지는 것처럼 보이는이 오류가 나타납니다. 나는 다른 크롬 창에서 http://localhost:9222을 열고 인터페이스를 디버깅 볼 수이기 때문에

Exception in thread "main" org.openqa.selenium.WebDriverException: chrome not 
reachable 

DevTools로 프로토콜 노력하고 있습니다.

누구나 함께이 두 가지를 얻을 수 있었습니까?

감사합니다 :)

다음
+0

디버깅 주소는 인수가 아닌 옵션으로 제공되어야합니다. –

+0

안녕하세요. 어떤 옵션이 될지 아십니까? 여기에 목록이 있습니다. https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup – RapidStar

+0

https://sites.google.com/a/chromium .org/chromedriver/capabilities –

답변

0

캐치는 "원격 디버깅 포트"스위치를 통과하면 다음 chromedriver는 여전히 내부적으로 RANDON 포트를 할당하는 버그를 가지고 있었고에 연결을 계속 시도보다는 9222 포트에 연결.

options.addArguments ("- remote-debugging-port = 9222");

이 명령 스위치를 건너 뛰고 chrome이 임의의 포트를 결정하고 chromedriver 로그에서이 포트 번호를 추출하도록하면 해결할 수 있습니다.

나는 그것을 작동시켰다. 그리고 여기 나는 그것에 대해 자세히 블로깅했다. 여기

https://medium.com/@sahajamit/selenium-chrome-dev-tools-makes-a-perfect-browser-automation-recipe-c35c7f6a2360

0

내가 이리저리 추가로 포트를 정의 방지하기 위해 ND remotedebugging 필요한 정보를 얻기 위해 할 것입니다. 그래서 그냥 jsontext에서 추출하는 어떤 코드로 교체, 궁금하지 마십시오 SeleniumLog-API

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
ChromeOptions options = new ChromeOptions(); 
options.setBinary(chromeBin); 
capabilities.setCapability(ChromeOptions.CAPABILITY, options); 
LoggingPreferences logPref = new LoggingPreferences(); 
logPref.enable(LogType.DRIVER, Level.ALL); 
driverInstance = new ChromeDriver(capabilities); 

LogEntries x = driverInstance.manage().logs().get(LogType.DRIVER); 
    for(LogEntry e:x.getAll()){ 
     if(e.getMessage().contains("DevTools request:")){ 
      String url = e.getMessage().replaceFirst("DevTools request:", "").trim(); 
     } 

     if(e.getMessage().contains("DevTools response:")){ 
      String json = e.getMessage().replaceFirst("DevTools response:", ""); 
      try { 
       if("page".equals(JSONUtil.get(json,"type"))){ 
        webSocketDebuggerUrl = JSONUtil.get(json,"webSocketDebuggerUrl"); 
       } 
      } catch (Exception e1) { 
       e1.printStackTrace(); 
      } 

     } 
     System.out.println(e.getMessage()); 
    } 

난 내 자신의 도구를 사용하는 JSONUtil을 통해 그것을 얻을.