2016-03-09 50 views
0

我有一個帶有Table1的屏幕。當單擊至少一列的單選按鈕時,我的邏輯起作用。但是當屏幕看起來像Table2時,我的邏輯在第二個if語句失敗,因爲它無法獲取'錯誤'中單擊無線電的數量。我需要找出有多少單選按鈕被點擊'缺陷','錯誤''學習機會'。有人可以幫助我如何制定一種適用於任何類型的屏幕顯示的通用邏輯。如何統計硒中單選按鈕的數量

表1

enter image description here

表2

enter image description here

我的邏輯

String reviewBorrowerAndCoborrowerOnlyTable = "//table[@id='borrowerAndCoborrowerOnlyTable']/tbody/tr/td"; 
     int defectBorrowerSize = 0, errorBorrowerSize = 0, learningOpportunityBorrowerSize = 0; 

     if (!driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='defect' and @aria-checked='true']")).isEmpty()) 
     { 
      List<WebElement> defectBorrower = driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='defect' and @aria-checked='true']")); 
      defectBorrowerSize = defectBorrower.size(); 
      System.out.println("The total selected Defect radio buttons is : " + defectBorrowerSize); 
     } 

     if (!driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='error' and @aria-checked='true']")).isEmpty()) 
     { 
      List<WebElement> errorBorrower = driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='error' and @aria-checked='true']")); 
      errorBorrowerSize = errorBorrower.size(); 
     } 

     if (!driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='learningOpportunity' and @aria-checked='true']")).isEmpty()) 
     { 
      List<WebElement> learningOpportunityBorrower = driver.findElements(By.xpath(reviewBorrowerAndCoborrowerOnlyTable + "/input[@value='learningOpportunity' and @aria-checked='true']")); 
      learningOpportunityBorrowerSize = learningOpportunityBorrower.size(); 
     } 

     int result = defectBorrowerSize + errorBorrowerSize + learningOpportunityBorrowerSize; 

和檢查AnjularJS代碼看起來像的下方。

<table class="table table-bordered table-striped" id="borrowerAndCoborrowerOnlyTable"> 
          <thead> 
          <tr> 
           <td> 
           </td> 
           <td colspan="5"> 
            Borrower <br> 
            <span class="boldCaseData ng-binding">ATDDCBRFNameTwentyThree ATDDCBRLNameTwentyThree</span> 
           </td> 
           <td></td> 
           <td colspan="5"> 
            Co-Borrower <br> 
            <span class="boldCaseData"></span> 
           </td> 
          </tr> 
          </thead> 
          <tbody> 
          <tr> 
           <td></td> 
           <td>Processor Validation</td> 
           <td>Satisfactory</td> 
           <td>Learning Opportunity</td> 
           <td>Error</td> 
           <td>Defect</td> 
           <td></td> 
           <td>Processor Validation</td> 
           <td>Satisfactory</td> 
           <td>Learning Opportunity</td> 
           <td>Error</td> 
           <td>Defect</td> 
          </tr> 
          <tr> 
           <td class="labelColumn">Borrower/Coborrower on account verification</td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="borrowerCoborrowerYesVerifcationPeerReviewRadio" class="ng-pristine ng-untouched ng-valid" name="217" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="borrowerCoborrowerYesVerifcationPeerReviewRadio" class="ng-pristine ng-untouched ng-valid" name="218" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="borrowerCoborrowerYesVerifcationPeerReviewRadio" class="ng-pristine ng-untouched ng-valid" name="219" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="borrowerCoborrowerYesVerifcationPeerReviewRadio" class="ng-pristine ng-untouched ng-valid" name="220" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td></td> 
           <td></td> 
           <td></td> 
           <td></td> 
           <td></td> 
           <td></td> 
          </tr> 

          <tr data-ng-show="nameRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">Name (First, Middle and Last)</td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="namePeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="221" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="namePeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="222" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="namePeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="223" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="namePeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="224" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="namePeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="225" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="namePeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-touched" name="226" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="namePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="227" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="namePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="228" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="generationCodeRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">Generation Code</td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="generationCodePeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="229" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="generationCodePeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="230" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="generationCodePeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="231" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="generationCodePeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="232" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td></td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="generationCodePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="233" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="generationCodePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="234" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="generationCodePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="235" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="generationCodePeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="236" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="ssnRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">SSN</td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="ssnPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="237" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="ssnPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="238" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="ssnPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="239" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="ssnPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="240" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td></td> 
           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="ssnPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="241" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="ssnPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="242" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="ssnPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="243" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="ssnPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="244" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="dobRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">DOB</td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="dobPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="245" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="dobPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="246" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="dobPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="247" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="dobPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="248" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="dobPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="249" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="dobPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="250" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="dobPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-touched" name="251" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="dobPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="252" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="telephoneNumberRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">Telephone Number</td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="telephoneNumberPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="253" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="telephoneNumberPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="254" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="telephoneNumberPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="255" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="telephoneNumberPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="256" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="telephoneNumberPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="257" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="telephoneNumberPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="258" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="telephoneNumberPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="259" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="telephoneNumberPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-touched" name="260" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="ecoaCodeRadioBorrower" aria-hidden="false"> 
           <td class="labelColumn">ECOA</td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="ecoaPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="261" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="ecoaPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="262" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="ecoaPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="263" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="ecoaPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="264" aria-checked="true" tabindex="0" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="ecoaPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="265" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="ecoaPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="266" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="ecoaPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="267" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="ecoaPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="268" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="caseToOpen.disputeType == 'Direct'" aria-hidden="false"> 
           <td class="labelColumn">Property Address (City, State and Zip)</td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="propertyAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="269" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="propertyAddressPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="270" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="propertyAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="271" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="propertyAddressPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="272" aria-checked="true" tabindex="0" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="propertyAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="273" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="propertyAddressPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-touched" name="274" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="propertyAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="275" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="propertyAddressPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="276" aria-checked="true" tabindex="0" aria-invalid="false"></td> 

          </tr> 
          <tr data-ng-show="caseToOpen.disputeType == 'Direct'" aria-hidden="false"> 
           <td class="labelColumn">Mailing Address (City, State and Zip)</td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="mailingAddressPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="277" aria-checked="true" tabindex="0" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="mailingAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="278" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="mailingAddressPeerReviewRadioBorrower" class="ng-valid ng-dirty ng-touched" name="279" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="mailingAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="280" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding">YES</td> 
           <td><input type="radio" value="satisfactory" data-ng-model="mailingAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="281" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="mailingAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="282" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="mailingAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="283" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="mailingAddressPeerReviewRadioCoborrower" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="284" aria-checked="true" tabindex="0" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="caseToOpen.disputeType == 'Indirect' &amp;&amp; previousAddressRadioBorrower" aria-hidden="true" class="ng-hide"> 
           <td class="labelColumn">Previous Address (City, State and Zip)</td> 

           <td class="ng-binding"></td> 
           <td><input type="radio" value="satisfactory" data-ng-model="previousAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="285" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="previousAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="286" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="previousAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="287" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="previousAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="288" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding"></td> 
           <td><input type="radio" value="satisfactory" data-ng-model="previousAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="289" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="previousAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="290" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="previousAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="291" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="previousAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="292" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          <tr data-ng-show="caseToOpen.disputeType == 'Indirect' &amp;&amp; currentAddressRadioBorrower" aria-hidden="true" class="ng-hide"> 
           <td class="labelColumn">Current Address (City, State and Zip)</td> 

           <td class="ng-binding"></td> 
           <td><input type="radio" value="satisfactory" data-ng-model="currentAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="293" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="currentAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="294" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="currentAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="295" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="currentAddressPeerReviewRadioBorrower" class="ng-pristine ng-untouched ng-valid" name="296" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

           <td></td> 

           <td class="ng-binding"></td> 
           <td><input type="radio" value="satisfactory" data-ng-model="currentAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="297" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="learningOpportunity" data-ng-model="currentAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="298" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="error" data-ng-model="currentAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="299" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 
           <td><input type="radio" value="defect" data-ng-model="currentAddressPeerReviewRadioCoborrower" class="ng-pristine ng-untouched ng-valid" name="300" aria-checked="false" tabindex="-1" aria-invalid="false"></td> 

          </tr> 

          </tbody> 
         </table> 
+0

請嘗試刪除不必要的代碼 – Prasad

+0

任何幫助表示讚賞請 – mmar

+0

http://stackoverflow.com/questions/23362768/how-to-check-if-radio-button-is-selected-or-未使用 - 硒的webdriver – Prasad

回答

1

這裏我寫了一些代碼。請檢查

public static void RadioTest() 
{ 
    FirefoxDriver driver;   
    driver = new FirefoxDriver(); 
    driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS); 
    //your URL 
    driver.get("YOUR URL "); 

    //Get All Readio Button from document 
    List<WebElement> listAllRadioButtons= driver.findElements(By.cssSelector("input[type='radio']")); 

    //Get All Readio Button Checked from document 
    List<WebElement> listAllRadioButtonsChecked= driver.findElements(By.cssSelector("input[type='radio']:checked")); 

    //Get All Readio Button from table 
    List<WebElement> listAllRadioButtonsFromTable = driver.findElements(By.cssSelector("table>tbody>tr>td>input[type='radio']")); 

    //Get All Readio Button Checked from table 
    List<WebElement> listAllRadioButtonsFromTableChecked = driver.findElements(By.cssSelector("table>tbody>tr>td>input[type='radio']:checked")); 

    //Get All td of specfic column 
    int colNumber = 3; 
    List<WebElement> listCol = driver.findElements(By.cssSelector("table>tbody>tr>td:nth-child("+colNumber+")")); 

    //Get All Radio Button of specfic column 
    //for example in your case to get all radio button of Defects 
    colNumber=6; 
    List<WebElement> listColRadioButton = driver.findElements(By.cssSelector("table>tbody>tr>td:nth-child("+colNumber+")>input[type='radio']")); 

    //Get All Radio Button Checked of specfic column 
    //for example in your case to get all radio button of Defects 
    colNumber=6; 
    List<WebElement> listColRadioButtonChecked = driver.findElements(By.cssSelector("table>tbody>tr>td:nth-child("+colNumber+")>input[type='radio']:checked")); 


    //Get All Radio Button of specfic Row 
    //for example in your case to get all radio button of SSN ROW 
    int rowNumber=5; 
    List<WebElement> listRowRadioButton = driver.findElements(By.cssSelector("table>tbody>tr:nth-child("+rowNumber+")>td>input[type='radio']")); 


    //Get All Radio Button Checked of specfic Row 
    //for example in your case to get all radio button of SSN ROW 
    rowNumber=5; 
    List<WebElement> listRowRadioButtonChecked = driver.findElements(By.cssSelector("table>tbody>tr:nth-child("+rowNumber+")>td>input[type='radio']:checked"));   
} 

希望你得到你想要的東西。 如果有任何問題,然後讓我知道。 謝謝。