1

我有一個表中的「案例」列表,我需要通過NAME找到特定的一個,然後單擊它。量角器 - 從表中獲取文本

我的HTML看起來像:

<tr ng-repeat-start="case in cases | orderBy:order:order_reverse" class="middle ng-scope odd readonly" ng-class-odd="'odd'" ng-class-even="'even'" ng-class="{readonly: !caseManager.isWritable(case)}"> 
        <td> 
         <span ax-sharing-circle="SHARED_WITH_PARTNER" class="ng-isolate-scope"><span class="icon sharing-circle sharing-circle-left" title="Sdílený"></span></span> 
        </td> 
        <td class="case-table-claim-number fix-v-align"> 
         <a ui-sref="case.general({caseId: case.caseId})" class="ng-binding" href="#/case/0a0b1c2a-94b4-444c-a2b8-c62cbd3532ae/general">20150629-165000-65</a> 
        </td> 
        <td class="case-table-claim-number fix-v-align ng-binding"></td> 
        <td class="case-table-claim-number fix-v-align ng-binding"></td> 
        <td class="case-table-make fix-v-align ng-binding"></td> 
        <td class="case-table-make fix-v-align ng-binding"></td> 
        <td class="case-table-status fix-v-align ng-binding"> 
         29.6.2015 
        </td> 
        <td class="case-table-status fix-v-align ng-binding"></td> 
        <td> 
         <span class="glyphicon glyphicon-menu-down" ng-class="{ 
           'glyphicon glyphicon-menu-up': hasOverview(case.caseId), 
           'glyphicon glyphicon-menu-down': !hasOverview(case.caseId), 
           }" ng-click="toggleOverview(case.caseId)"></span> 
        </td> 
       </tr> 

在上例中,你可以找到字符串20150629-165000-65這是案件的名稱。

我嘗試寫這樣的事:

element(by.cssContainingText('a', global.caseNumber)).click(); 

應該找到元素,點擊它,而不是它拋出錯誤:

No element found using locator: by.cssContainingText("a", "20150629-165000-65")

有人能告訴我如何做到這一點?

回答

1

有一個相關的by.linkText()定位器應該適合用例:

var link = element(by.linkText(global.caseNumber)); 

如果仍無法找到所需的元素,嘗試添加等待:

var EC = protractor.ExpectedConditions; 
browser.wait(EC.presenceOf(link), 5000); 
+0

正確一如既往:)謝謝(儘快將它標記爲可能) – Andurit