2011-01-24 7 views
1

기본적으로 URL을 반복적으로로드하고 테스트 프로세스와 같은 특정 요소의 값을 확인하고 해당 흐름에 대한 서버 로그를 모니터링하려고합니다.그리스 - 원숭이를 사용하여 반복적으로 웹 페이지를로드하고 요소를 확인하는 방법은 무엇입니까?

추가 처리를 위해 동일한 호스트를 반복적으로 사용하여 프로덕션 트래픽의 일부를 모방하려고합니다. 이 문제를 가장 잘 해결하려면 어떻게해야합니까?

흐름

로드 웹 페이지 -> 모니터 서버 로그 -> 프론트 엔드의 특정 요소 값을 모니터 -> 다시 반복합니다.

답변

1

내가 Selenium은 시나리오에 가장 적합한 테스트 도구임을 알아 낸 : 여기

그러나

은 요소에 대해 반복적으로 체크 페이지를로드하는 스크립트입니다.

FF 애드온으로 셀레늄 IDE를 설치하고 일련의 명령 아래 시도 : - 확인해야 할 요소가 지연된 AJAX 호출보다 페이지로드에 사용할 수있는 경우

Command | Target | Value 
1) open | _url_ | _blank_ | 
2) waitForElementPresent | css=_selector_ or xpath=_selector_ | _time in ms_ | 
3) verifyElementPresent | css=_selector_ or xpath=_selector_ | _blank_ | 

당신은 2 단계를 건너 뛸 수 있습니다.

위의 단계 중 하나라도 실패하면 실패합니다. 이것을 'n'번 실행하도록 예약 할 수 있습니다.

1

Greasemonkey는 load testing 웹 페이지/서버/앱을위한 최고의 도구가 아닙니다.

// ==UserScript== 
// @include   http://xyz.co.in/* 
// @require   http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js 
// ==/UserScript== 

$(document).ready (Greasemonkey_main); 

function Greasemonkey_main() 
{ 
    do 
    { 
     var TargetNode = $("#TargetNode"); //-- Look for node with id, "TargetNode". 

     if (TargetNode && TargetNode.length) 
     { 
      //--- Maybe also check contents: 
      if (/Node contents to search for/i.test (TargetNode.text())) 
      { 
       alert ("We found what we're looking for"); 
       break; 
      } 
     } 

     //--- Failsafe check on number of reloads 
     var NumReloads = parseInt (document.location.search.replace (/.*num_gm_reloads=(\d+).*/, "$1")) 
     if (NumReloads > 2) 
     { 
      alert ("After 2 reloads, we still didn't find what we were looking for."); 
      break; 
     } 

     //--- We neither found the stop code nor exhausted our retries, so reload the page. 
     if (NumReloads) 
      NumReloads++; 
     else 
      NumReloads = 1; 

     var TargetURL = window.location.href; 
     //--- Strip old URL param, if any. Note that it will always be at the end. 
     TargetURL  = TargetURL.replace (/(.*?)(?:\?|&)?num_gm_reloads=\d+(.*)/, "$1$2"); 
     var ParamSep = /\?/.test (TargetURL) ? "&" : "?"; 

     TargetURL  = TargetURL + ParamSep + 'num_gm_reloads=' + NumReloads; 

     window.location.href = TargetURL; //-- Reload the page. 

    } while (0) 
} 
+0

도움을 주셔서 감사합니다! Selenium (FF addon)은 이러한 테스트를 수행하는 데 가장 좋은 도구입니다. – Ravikiran

관련 문제