0

在量角器中,我无法检索与位于我的单页应用程序的 Ionic1 标题中的按钮相对应的元素。

  • 当我试图让它通过时element(by.id("toolButton")),我收到一个警告,说有几个这样的对象,并且量角器会拿第一个。然后,当我执行单击时,我收到一条错误消息,指出该元素不可见。随着browser.wait(EC.visibilityOf(btn), 5000)我超时。在 Chrome 中挖掘似乎有 2 个页面实例:一个带有<div class="nav-bar-block" nav-bar="active">,另一个带有nav-bar="cached"而不是"active"。所以我猜量角器捕获了缓存的实例。(顺便说一句,我不知道为什么有缓存版本,我的 UI 路由器cache:false对每个状态都说)。

  • 当我使用 Elementor 找到唯一标识按钮的方法时,它告诉我log: "Cannot find suggestions".

请问有什么办法解决这个问题吗?

您将在下面找到工具栏的屏幕截图,以及显示工具栏的 2 个实例的 HTML 代码摘录。该按钮是标记为“+”的按钮。

标题工具栏截图

<ion-nav-bar class="bar-balanced ng-class:$root.backgroundClass nav-bar-container contact-background" nav-bar-transition="ios" nav-bar-direction="forward" nav-swipe="" style="">
  <ion-nav-back-button class="hide"></ion-nav-back-button>
  <ion-nav-buttons side="left" class="hide"></ion-nav-buttons>
  <ion-nav-buttons side="right" class="hide"></ion-nav-buttons>

  <div class="nav-bar-block" nav-bar="active">
    <ion-header-bar class="bar-balanced ng-class:$root.backgroundClass bar bar-header contact-background" align-title="center" style="">
      <button ng-click="$ionicGoBack()" class="button back-button buttons button-clear header-item"><i class="icon ion-ios-arrow-back"></i>          
        <span class="back-text" style="transform: translate3d(0px, 0px, 0px);"><span class="default-title hide">Back</span>
        <span class="previous-title">Accueil</span></span>
      </button>
      <div class="buttons buttons-left header-item"><span class="left-buttons">
        <button id="leftMenuBtn" class="button button-icon button-clear ion-navicon" menu-toggle="left">
        </button></span>
      </div>
      <div class="title title-center header-item" style="transform: translate3d(0px, 0px, 0px); left: 114px; right: 114px;"><span class="nav-bar-title">
        <i class="icon ion-person"></i> Contacts</span>
      </div>
      <div class="buttons buttons-right header-item"><span class="right-buttons">
        <button id="toolButton" class="button button-icon button-clear ng-class:$root.toolButtonIcon ion-plus" ng-click="$root.toolClick()" style=""></button>
        <button class="button button-icon button-clear ion-ios-film" menu-toggle="right" ng-disabled="$root.getLogin() == null"></button></span>
      </div>
    </ion-header-bar>
  </div>

  <div class="nav-bar-block" nav-bar="cached">
    <ion-header-bar class="bar-balanced ng-class:$root.backgroundClass bar bar-header contact-background" align-title="center" style="">
      <button ng-click="$ionicGoBack()" class="button back-button hide buttons  button-clear header-item" style="opacity: 0;"><i class="icon ion-ios-arrow-back"></i>          
        <span class="back-text" style="transform: translate3d(0px, 0px, 0px); opacity: 0;"><span class="default-title">Back</span>
        <span class="previous-title hide"></span></span>
      </button>
      <div class="buttons buttons-left header-item" style="opacity: 0;"><span class="left-buttons">
        <button id="leftMenuBtn" class="button button-icon button-clear ion-navicon" menu-toggle="left">
        </button></span>
      </div>
      <div class="title title-center header-item" style="left: 56px; right: 56px; transform: translate3d(-123.172px, 0px, 0px); opacity: 0;"><span class="nav-bar-title">
        <i class="icon ion-home"></i> Accueil</span>
      </div>
      <div class="buttons buttons-right header-item" style="opacity: 0;"><span class="right-buttons">
        <button id="toolButton" class="button button-icon button-clear ng-class:$root.toolButtonIcon ion-plus" ng-click="$root.toolClick()"></button>
        <button class="button button-icon button-clear ion-ios-film" menu-toggle="right" ng-disabled="$root.getLogin() == null"></button>
          </span></div></ion-header-bar></div></ion-nav-bar>

4

0 回答 0