목록을 검사 할 때 결과의 첫 페이지에 목록의 항목이 두 개 이상 있습니까?
다양한 유형의 검색 결과가 여러 개인 사이트를 테스트하고 모두 정렬 순서를 확인하는 테스트를 거칩니다.
- 목록의 방향이 ASC인지 DSC인지를 확인하는 방법이 있는지 확인해야합니다. "css = th.sortasc"또는 "css-th.sortdsc"와 같은 요소가 있는지 확인하여 방향을 확인하십시오.
- 일단 그렇게 할 수 있다면 목록의 두 값 (목록의 첫 번째 값과 다음 페이지 또는 하위 값)을 비교 한 다음 비교하여 값이 큰지 또는 작은지를 확인하십시오. 다른.
- 숫자 또는 문자열로되어 있는지에 따라 데이터를 정리해야 할 수도 있습니다.
테스트를 수행하기 위해 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'] < storedVars['2ndRowName']);</td>
<td>isLess</td>
</tr>
<tr>
<td>verifyExpression</td>
<td>${isLess}</td>
<td>true</td>
</tr>
}이 도움이
희망. - Klendathu
네, 그게 내가 지금 발견 한 유일한 방법 인 것 같습니다. 하지만 두 locator 값이 같아서 결국 비교할 수있는 다른 값을 가진 두 개의 레코드를 만들기로 결정했습니다. 검색 조건을 좁혀서 두 레코드가 같은 페이지에 표시되도록해야합니다. – Echo