使用css识别图像对象以实现量角器自动化

使用css识别图像对象以实现量角器自动化,css,angularjs,css-selectors,protractor,Css,Angularjs,Css Selectors,Protractor,我正在使用量角器进行角度自动化。我正在尝试使用css标识符从下面的元素结构中获取“fa-fa-something”文本- <div class="Itemlistcontainer"> <ul class="itemlist sortlist ui-sortable"> <!-- ngRepeat: Item in Items | orderBy:CustomSort:false --><li ng-repeat=" Item i

我正在使用量角器进行角度自动化。我正在尝试使用css标识符从下面的元素结构中获取“fa-fa-something”文本-

<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.fa.fa-something').getAttribute('class').getText() 
    

    要确定“fa-fa-something”在项目中找到的是什么项目,您可能需要一个ID(这将更容易阅读,无需通过提取
    fa-fasomething
    等来解析类属性。

    对我来说不起作用,因为要查找'fa-fa-something',我需要根据您的解决方案在css标识符中使用'fa.fa-something'。您的问题不清楚,请再添加一些单元测试代码
    getAttribute('class')。getText()
    永远不会工作,您对
    class
    属性不做任何操作,
    getText()
    工作,因为
    ElementFinder
    是可链接的,仅此而已。
    element(By.css('ul.itemlist i.fa.fa-something').getAttribute('class').getText()