2016-12-06 7 views
0

저는 Selenium IDE를 처음 사용하므로 필요에 따라 목록 순서를 확인해야합니다. 데이터베이스에서 얻은 일부 레코드를 나열합니다. 특정 값을 갖는 두 개의 레코드를 생성 할 수 있고 verifyOrdered 또는 assertOrdered를 사용하여 레코드를 얻을 수 있다는 것을 알고 있습니다. 그러나 우리는 ID DESC 또는 ASC 사전 이름과 같은 정렬 순서가 다르며 페이지 매김 도구가 있으므로 생성 된 두 레코드가 같은 페이지에 표시되지 않을 수 있습니다.어떻게 알파벳순 정렬 또는 ID 감소와 같이 Selenium IDE에서 필요에 따라 주문 결과를 검증 할 수 있습니까

그래서 ID desc와 같은 값을 모른 채 특정 로케이터 목록의 순서를 확인할 수있는 유용한 방법이 있습니까? 미리 감사드립니다.

답변

0

목록을 검사 할 때 결과의 첫 페이지에 목록의 항목이 두 개 이상 있습니까?

다양한 유형의 검색 결과가 여러 개인 사이트를 테스트하고 모두 정렬 순서를 확인하는 테스트를 거칩니다.

  1. 목록의 방향이 ASC인지 DSC인지를 확인하는 방법이 있는지 확인해야합니다. "css = th.sortasc"또는 "css-th.sortdsc"와 같은 요소가 있는지 확인하여 방향을 확인하십시오.
  2. 일단 그렇게 할 수 있다면 목록의 두 값 (목록의 첫 번째 값과 다음 페이지 또는 하위 값)을 비교 한 다음 비교하여 값이 큰지 또는 작은지를 확인하십시오. 다른.
  3. 숫자 또는 문자열로되어 있는지에 따라 데이터를 정리해야 할 수도 있습니다.

테스트를 수행하기 위해 Selenium과 RobotFramework를 사용하고 있습니다. 여기에 수행중인 샘플 코드가 있습니다. {

Click Element ${Name_Column_Header} #clicks the header to sort the column. 
Sleep 2s 
Element Should Be Visible css=th.sortdsc > a #verifies the sort caret is shown and it's descending. 
#next 3 lines grab the text from the field (in this case, person names) 
${Name1} Get Text css=td.ng-binding 
${Name2} Get Text //tbody[2]/tr/td 
${Name3} Get Text //tbody[3]/tr/td 
#next lines grab just the last name from each name, since list is sorted by last name. 
${N1} Fetch From Right ${Name1} ${SPACE} 
${N2} Fetch From Right ${Name2} ${SPACE} 
${N3} Fetch From Right ${Name3} ${SPACE} 
#next two lines do the compare, verifying that the name in line 1 is greater than the name in line 2, and line 2 name is greater than line 3 
Should Be True '${N1}' >= '${N2}' 
Should Be True '${N2}' >= '${N3}' 

} 셀레늄 IDE에서

, 명령은 매우 유사하다.

{

<!--Sort by name--> 
<tr> 
    <td>clickAndWait</td> 
    <td>link=Name</td> 
    <td></td> 
</tr> 
<!--Grab values for name from 1st and 2nd row--> 
<tr> 
    <td>storeText</td> 
    <td><locator value> 
    <td>1stRowName</td> 
</tr> 

<tr> 
    <td>storeText</td> 
    <td><locator value> 
    <td>2ndRowName</td> 
</tr> 
<!--evaluate that 1st row name is less than or equal to 2nd row name--> 
<tr> 
    <td>storeEval</td> 
    <td>var isLess = false; isLess = eval(storedVars['1stRowName'] &lt; storedVars['2ndRowName']);</td> 
    <td>isLess</td> 
</tr> 
<tr> 
    <td>verifyExpression</td> 
    <td>${isLess}</td> 
    <td>true</td> 
</tr> 

}이 도움이

희망. - Klendathu

+0

네, 그게 내가 지금 발견 한 유일한 방법 인 것 같습니다. 하지만 두 locator 값이 같아서 결국 비교할 수있는 다른 값을 가진 두 개의 레코드를 만들기로 결정했습니다. 검색 조건을 좁혀서 두 레코드가 같은 페이지에 표시되도록해야합니다. – Echo