2014-10-07 76 views
-2

我正在使用量角器實現角度js自動化。我想用css來從以下要素結構的「發發出頭的」文本identifier-使用css實現量角器自動識別圖像對象

<div class="Itemlistcontainer"> 
     <ul class="itemlist sortlist ui-sortable"> 
     <!-- ngRepeat: Item in Items | orderBy:CustomSort:false --><li ng-repeat=" Item in Items | orderBy:CustomSort:false" ng-show="!searchinput || ([Item.Name]|filter:searchinput).length" ng-class="{ 'itemdisabled' : !CanUseTask(Item) || deactivate }" class="ng-scope ui-draggable"> 
     <div bo-attr="" bo-attr-id="Item.Id" bo-attr-title="Item.Details | html2string" class="label itemlabel" id="3d991564-a1a9-49ab-8659-a26e00fbfae6" title="Blah blah blah."> 
      <span> 
      <i ng-class="itemIconClass(Item)" style="margin-right: 5px;" class="fa fa-something"></i> 
      </span><span bo-text="item.Name | ellipse : 32">Item Name</span> 
     </div> 
     <!--ngRepeat: Item in Items....and the list goes on 

我需要下的項目是什麼項目要知道,發現這個「發發出頭」。我正在使用element(By.css('ul.itemlist i.itemIconClass(Item)').getAttribute('class').getText() 這是行不通的。

+0

'的getAttribute(「類」)。gettext的()'不會有任何效果,你正在做這裏沒有'class'屬性,'getText()'起作用,因爲'ElementFinder'是可鏈接的。 – 2014-10-07 16:31:21

回答

2
element(By.css('ul.itemlist i.itemIconClass(Item)').getAttribute('class').getText() 
如你想在一個量角器元素選擇

我認爲你需要插角模板表達

不能工作:

element(By.css('ul.itemlist i.fa.fa-something').getAttribute('class').getText() 

,並確定what Item in Items was this 'fa fa-something' found也許你需要一個ID(這將是更容易閱讀,無需通過提取fa fasomething等來解析類屬性...

+0

對於我來說不適用於尋找'fa fa-something'我需要根據您的解決方案在css標識符中使用'fa.fa-something'。 – 2014-10-07 08:15:52

+1

你的問題在不清楚的時候,增加一些更多的單元測試代碼 – 2014-10-07 08:18:19