2013-10-29 73 views
0

我想測試中崩潰組排序排序?它有可能與否?請分享,如何做到這一點。吹PIC有兩個第1組)分行:克利夫頓和2)科:。Holsopple(列通過單擊列標題(聯繫人排序,類型等)),下文提到的代碼工作在那裏是不存在的組,但未能在哪裏羣組頁面。如何驗證崩潰組硒網絡驅動程序的Java

當我在java中比較了gettext它顯示導致錯誤,而頁面上的文本的排序是正確的,因爲我的Java代碼獲取在整列和分類文本處於崩潰組。我想寫這驗證了崩潰組基本列排序的代碼。

HTML是在這裏:

<tbody> 
<tr class="rgGroupHeader"> 
<td class="rgGroupCol"> 
<td colspan="9"> 
<p>Branch: Clifton</p> 
</td> 
</tr> 
<td class="rgGroupCol"/> 
<td style="display:none;" title="289855">289855</td> 
<td style="display:none;" title="31">31</td> 
<td style="display:none;"/> 
<td style="display:none;" title="12">12</td> 
<td style="display:none;" title="6">6</td> 
<td class="col_priority"> 
<td title="10/24/2013">10/24/2013</td> 
<td class="col_status"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl19_divStatus" class="status_active" title="Open - Active"/> 
</td> 
<td> 
<td> 
<td> 
<td title="Nawaz, S (10/22/2013)"> 
<td class="col_manager_instruction"> 
<td class="col_expiry" title="N/A">N/A</td> 
</tr> 
<tr id="ctl00_CPHPageContents_dtgLeads_ctl00__8" class="rgRow"> 
<td class="rgGroupCol"/> 
<td style="display:none;" title="289856">289856</td> 
<td style="display:none;" title="31">31</td> 
<td style="display:none;"/> 
<td style="display:none;" title="11">11</td> 
<td style="display:none;" title="6">6</td> 
<td class="col_priority"> 
<td title="10/24/2013">10/24/2013</td> 
<td class="col_status"> 
<td> 
<td> 
<td> 
<td title="Nawaz, S (10/22/2013)"> 
<td class="col_manager_instruction"> 
<td class="col_expiry" title="11/25/2013">11/25/2013</td> 
</tr> 
<tr class="rgGroupHeader"> 
<td class="rgGroupCol"> 
<input id="ctl00_CPHPageContents_dtgLeads_ctl00__35__0" class="rgCollapse" type="button" title="Collapse group" onclick="$find("ctl00_CPHPageContents_dtgLeads_ctl00")._toggleGroupsExpand(this, event); return false;__doPostBack('ctl00$CPHPageContents$dtgLeads$ctl00$ctl37$ctl00','')" value=" " name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl37$ctl00"/> 
</td> 
<td colspan="9"> 
<p>Branch: Holsopple</p> 
</td> 
</tr> 
<tr id="ctl00_CPHPageContents_dtgLeads_ctl00__16" class="rgRow"> 
<td class="rgGroupCol"/> 
<td style="display:none;" title="289768">289768</td> 
<td style="display:none;" title="2">2</td> 
<td style="display:none;"/> 
<td style="display:none;" title="12">12</td> 
<td style="display:none;" title="4">4</td> 
<td class="col_priority"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divPriority" class="priority_high" title="High"/> 
</td> 
<td title="06/27/2013">06/27/2013</td> 
<td class="col_status"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divStatus" class="status_active" title="Open - Active"/> 
</td> 
<td> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divInner"> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_hlnkContact" href="/Leads/Research/289768">John Ross</a> 
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_hdfContactID" type="hidden" value="174120" name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl38$hdfContactID"/> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divContactCardControl" class="pos_r"/> 
</div> 
</td> 
<td> 
<div class="lead_type"> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkType" class="lead_type_link" href="/Leads/Research/289768" title="Maturing CD 100">Maturing CD 100</a> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkDownArrow" class="down_arrow" onclick="showCloseTransferLayer('ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_CloseTransferLayer')" href="javascript:;"/> 
<span class="pos_r"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_CloseTransferLayer"> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkCloseLead" onclick="return ShowPopupForm('/Forms/Popups/CloseLead.aspx?LeadID=289768','WindowCloseLead');" href="javascript:;">Cancel Lead</a> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkTransferLead" onclick="return ShowPopupForm('/Forms/Popups/TransferLead.aspx?LeadID=289768','WindowTransferLead');" href="javascript:;">Transfer Lead</a> 
</div> 
</span> 
</div> 
</td> 
<td> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divAssignedTo"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo" class="RadComboBox RadComboBox_Default assigned_to_combo" style="width:160px;"> 
<table style="border-width: 0px; border-collapse: collapse;" summary="combobox"> 
<tbody> 
<tr class="rcbReadOnly"> 
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;"> 
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_Input" class="rcbInput radPreventDecorate" type="text" readonly="readonly" value="Org, T" name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl38$ddlAssignedTo" autocomplete="off"/> 
</td> 
<td class="rcbArrowCell rcbArrowCellRight"> 
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a> 
</td> 
</tr> 
</tbody> 
</table> 
<div class="rcbSlide" style="z-index:6000;"> 
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Default " style="display:none;"> 
<div class="rcbScroll rcbWidth" style="width:100%;"> 
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;"> 
<li class="rcbItem">Ghaffar, A</li> 
<li class="rcbItem">Keller, K</li> 
<li class="rcbItem">Nawaz, S</li> 
<li class="rcbItem">Org, 1</li> 
<li class="rcbItem">Org, T</li> 
</ul> 
</div> 
</div> 
</div> 
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_ClientState" type="hidden" name="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_ClientState" autocomplete="off"/> 
</div> 
</div> 
</td> 
<td/> 
<td class="col_manager_instruction"> 
<td class="col_expiry" title="N/A">N/A</td> 
</tr> 

</tbody> 

Image is attached for more description

Java代碼:

List<String> displayedNames = new ArrayList<String>(); 
     List<String> SortedNames = new ArrayList<String>(); 
     String getData; 

     Thread.sleep(thread); 

     for(int i=0;i<tableType.size();i++) 
     { 

      getData=tableType.get(i).getText(); 
      System.out.println(getData); 
      displayedNames.add(getData); 
      SortedNames.add(getData); 


     } 
     System.out.println(displayedNames); 

     Thread.sleep(thread); 

     List<String> sortingOperation = displayedNames; 

     Thread.sleep(thread); 

     Collections.sort(sortingOperation); 

     Thread.sleep(thread); 

     Assert.assertEquals(SortedNames, sortingOperation); 
+0

你能更新HTML源代碼的問題? – Hemanth

+0

我已經發布了HTML在上面的查詢,請查看。 –

回答

0
List<String> displayedNames = new ArrayList<String>(); 
List<String> SortedNames = new ArrayList<String>(); 
Thread.sleep(10000); 
WebElementtableType=action.driver.findElement(By.xpath("//[@id='table_1_core_table_content']/tbody/tr")); 
Thread.sleep(10000); 
List<WebElement>rowElmt=tableType.findElements(By.xpath("//tr/td[5]")); 
String getData; 
Thread.sleep(5000); 
for(int i=2;i<rowElmt.size();i++) 
{ 

    getData=rowElmt.get(i).getText(); 
    displayedNames.add(getData); 
    SortedNames.add(getData); 


} 

System.out.println(displayedNames); 
Thread.sleep(5000); 
List<String> sortingOperation = displayedNames; 
Collections.sort(sortingOperation); 
Assert.assertEquals(SortedNames, sortingOperation); 

}

+0

它爲我的測試工作。如果有任何懷疑,然後告訴我 – satish

+0

歡迎計算器,你可能會更好,編輯您的意見到你的答案。爲了清楚起見,關於您的更改的幾個句子也可能有所幫助。 – Caleryn