在量角器中找不到使用定位器错误的元素

时间:2015-10-07 10:33:57

标签: angularjs ionic-framework protractor

在我的测试阶段,我想测试html中的标题元素h2

<a class="item-content" ng-href="#/lead/details/1/" target="_self" href="#/lead/details/1/">

                <div class="row" style="height: 35px; width: 100%; margin-left:-10px; margin-top: -10px; margin-right: 0px; padding: 0px"> 
                    <div class="col col-top col-67">
                        <h2 class="ng-binding">HAL 9000</h2>
                        <br>
                        <h4 style="font-weight: normal; margin-top: -15px" class="ng-binding">Jupiter &nbsp; Feb 10, 2025 </h4>
                    </div>

                    <div class="col col-center col-10 col-offset-25" style="margin-right: -10px">
                        <a href="tel:9876543210" ng-click="$event.stopPropagation()">
                            <i class="icon ion-ios-telephone-outline" style="font-size: 36px"></i>                       
                        </a>
                    </div>
                    <div class="col col-center col-20" style="margin-left: 15px">
                        <a href="mailto:hai@spaceodyssey.com?Subject=Hi;" ng-click="$event.stopPropagation()">
                            <i class="icon ion-ios-email-outline" style="font-size: 36px;"></i>
                        </a>
                    </div>
                </div>        
            </a>

我想测试一下&#34; Hal 9000&#34;在我的量角器测试过程中有人帮我找到它是可见的 在我的量角器中,我使用了

var child = element(by.css(&#39; .col col-top.col-67&#39;)),element(by.css(&#39; .ng-binding&#39;)) ;

it('20 should update 2nd lead with proper data',function(){
expect(child.getText()).toBe('HAL 9000'); });

我的终端收到错误信息 NoSuchElementError:找不到使用locator找到的元素:By.cssSelector(&#34; .col col-top.col-67&#34;) 有人帮我解决这个问题

1 个答案:

答案 0 :(得分:0)

对于更精确的定位器,您可以始终使用:

<nav class="navbar">    
    <div class="container">
        <div class="navbar-header">
            <label for="toggle" class="sidebar-toggle"></label>
        </div>
        <input type="checkbox" id="toggle" />
        <div class="sidebar"></div>
    </div>
</nav>