2017-09-05 11 views
0

특정 URL에 대해 네트워크에서 총 요청 수를 얻고 싶습니다. 셀레늄 또는 셀레니움을 사용하여 어떻게 할 수 있습니까? 내 웹 페이지에 검색 창이 있습니다. 검색 상자에 입력을 시작하면 자동 완성 결과가 표시되고 입력 한 모든 문자에는 요청이 있습니다. 얼마나 많은 시간 요청을했는지 확인하고 싶습니다.셀레늄/셀레늄 웹 드라이브를 사용하여 초당 총 요청 수를 얻는 방법

셀레늄 webdriver를 사용하여 가능하다면 누군가에게 도움이 될만한 조언이나 힌트를 줄 수 있습니까?

답변

0

예는 JavascriptExecutor

코드를 사용하여 아래와 같은 것을 할 수 있습니다 : -

ChromeOptions options = new ChromeOptions(); 
options.addArguments("start-maximized"); 
DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
capabilities.setCapability(ChromeOptions.CAPABILITY, options); 
WebDriver driver = new ChromeDriver(capabilities); 
driver.get("http://www.google.com"); 
String scriptToExecute = "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;"; 
String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString(); 
System.out.println(netData); 

첫 번째 코드 retrun 네트워크 반환 네트워크를, "이 태그를 JS의 당신은 기업의 JS 코드를 제거 할 수 있기 때문이다. 당신이 필요하지 않아

희망이 당신을 도울 것입니다 :