2016-07-06 8 views
0

動的要素の位置を特定し、分度器を使用してその要素に値を送信してください。ここ は、入力フィールドが動的にページにロードされている私のpurchaseInfo.htmlコードスニペット、次のとおりです。分度器の動的入力フィールドとパス値を見つける方法

<div class="row subpage-submit-flow"> 
    <div class="col-md-12"> 
    <!-- progress bar --> 
    <uib-progressbar value="45" class="in-progress"></uib-progressbar> 
    <!-- end progress bar --> 
    <div class="page-header"> 
     <h2 id="purchaseInfo-header" translate="content.PURCHASE_INFO_HEADER"></h2> 
     <p id="purchaseInfo-reqFieldLbl" translate="content.PURCHASE_INFO_REQUIRED_FIELD_LABEL"></p> 
    </div> 
    <div class="row"> 
     <div class="col-md-12"> 
     <p ng-show="purchaseInfo.$invalid" class="error-message pull-right"> 
      *Please complete all required fields. 
     </p> 
     </div> 
    </div> 
    <div class="clearfix"></div> 
    <div class="row"> 
     <div ng-class="purchaseInfoCtrl.receiptImage ? 'col-md-6' : 'col-md-12'"> 
     <form name="purchaseInfo" novalidate> 
      <div ng-if="webAttributes" class="row"> 
       <div ng-repeat="webAttribute in webAttributes track by $index"> 
       <div class="clearfix" ng-if="$index % 2 == 0"></div> 
       <div ng-class="purchaseInfoCtrl.receiptImage ? 'col-md-12' : 'col-md-6'"> 
        <div ng-if="purchaseInfoCtrl.isTextField(webAttribute) || purchaseInfoCtrl.isCurrencyField(webAttribute)" 
         class="form-group"> 
         <p class="noMargin" 
          ng-show="purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$viewValue || webAttribute.focused" 
          ng-class="(purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$invalid && purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$dirty) ? 'input-error-label' : (webAttribute.focused) ? 'activeFieldLabel' : 'inactiveFieldLabel'"> 
         <span>{{ webAttribute.displayValue }}</span> 
         </p> 
         <input id="{{ webAttribute.name }}" border-color ng-if= "webAttribute.webAttributeType == 'C'" ng-focus="purchaseInfoCtrl.focus($event)" 
          ng-blur="purchaseInfoCtrl.blur($event)" 
          ng-class="purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$dirty && purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$invalid ? 'input-error' : ''" 
          class="noBorderTextBox" type="text" class="form-control noBorderTextBox" name="{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}" 
          ng-model="purchaseInfoCtrl.model.attributes[webAttribute.webAttributeIndex].value" 
          placeholder="{{ webAttribute.displayValue }}" 
          ng-required="webAttribute.mandatory" 
          ng-pattern="/^[^<%>\\\\]+$/"> 
         <input id="{{ webAttribute.name }}" border-color ng-if= "webAttribute.webAttributeType == 'P'" ng-focus="purchaseInfoCtrl.focus($event)" 
          ng-blur="purchaseInfoCtrl.blur($event)" 
          ng-class="purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$dirty && purchaseInfo.{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}.$invalid ? 'input-error' : ''" 
          class="noBorderTextBox" type="text" class="form-control noBorderTextBox" name="{{webAttribute.webAttributeType}}{{webAttribute.webAttributeIndex}}" 
          ng-model="purchaseInfoCtrl.model.product.attributes[webAttribute.webAttributeIndex].value" 
          placeholder="{{ webAttribute.displayValue }}" 
          ng-required="webAttribute.mandatory" 
          ng-pattern="/^[^<%>\\\\]+$/"> 
        </div> 

私はページオブジェクトパターンを、次の午前と私のpurchaseInfo-pageObject.jsクラスで、私は機能の下にこれを書かれているし、これをpurchaseInfo_spec.jから呼び出します。意外にも、sendKeysは動作していませんが、& sendvaluesがコンソールに表示されています。助けてください。私はそれを感謝します。前もって感謝します。

this.inputFieldsAll = function(){ 
this.inputElems = element.all(by.repeater('webAttribute in webAttributes track by $index')).get(1); 
if (this.inputElems.isDisplayed()){ 
this.inputElems.sendKeys('764763688888'); 
console.log('dispalyed&sendvalues'); 
} 
this.inputElems.getText().then(function(val){ 
    console.log('value: ',val); 
}); 
+0

2番目の入力IDにアクセスしようとしていますか? –

+0

@priya UIのスクリーンショットを添付したり、インタラクションする要素を正確に記述してください –

答えて

1

まず第一に、あなたの現在のコードに大きな問題がある:

if (this.inputElems.isDisplayed()) { 

isDisplayed()が故に条件は関係なく、常に真である、常に「truthy」である約束を返します。実際の表示状態。

もう1つの問題は、キーを送信しようとしている要素に関連しています。現在、リピータに一致するdiv要素にキーを送信しています。代わりに、内部のinput要素を見つける必要があります。

var inputs = element.all(by.repeater('webAttribute in webAttributes')).get(1).all(by.tagName("input")); 
inputs.first().sendKeys("764763688888"); 
関連する問題