2017-06-19 29 views
-1

我從網站的代碼如下,我想用從代碼段跌破5日線<input type="text" placeholder="Enter Workflow Name"Selenuim /量角器無法找到或單擊文本框

代碼

<div class="workflow-container ng-scope" data-ng-controller="sourceCode.Designer.uiComponents.conciergeScreen.templates.NewWorkflowController"> 
<div class="input"> 
    <div class="wrapper top" data-ng-class="{'fill': hosted === true}"> 
     <label class="welcome">What should your workflow be called?</label> 
     <input type="text" placeholder="Enter Workflow Name" class="workflow-name-textbox ng-valid ng-not-empty ng-touched ng-dirty ng-valid-parse" data-ng-class="{'error': errors.error}" autofocus="" data-ng-focus="select($event)" data-ng-model="conciergetitle" data-ng-model-options="{ updateOn: 'default blur', debounce: { default: 300, blur: 300 } }" data-ng-change="inputchange(designeritems)" data-ng-keyup="$event.keyCode == 13 &amp;&amp; createnewstudioitem(designerItems[0], conciergetitle, $event)" style=""> 
     <div class="errogory"> 
      <div class="summary"> 
       <!-- ngIf: errors.error || errors.category --> 
      </div> 
      <div class="category" data-ng-click="categorypicker($event)"> 
       <label>Folder</label> 
       <i class="icon icon-set-assetbrowser icon-size16 ic-categoryserver"></i> 
       <a href="javascript:void(0)" data-ng-class="{ 'error': errors.category }" title="Workflow" class="ng-binding">Workflow</a> 
      </div> 
     </div> 
     <div class="concierge-button-grid"> 
      <div class="concierge-button-container"> 
       <button id="createWorkflow" data-button-error="false" class="concierge-button button-command" data-ng-disabled="!newWorkflowReady" data-ng-class="{ 'error': errors.button, 'is-disabled error' : errors.button }" data-ng-click="createnewstudioitem(designerItems[0], conciergetitle, $event)" disabled="disabled"> 
        <!-- ngIf: !errors.button --><span data-ng-bind="getString('new_workflow_create_button')" data-ng-if="!errors.button" class="ng-binding ng-scope">Create</span><!-- end ngIf: !errors.button --> 
        <!-- ngIf: errors.button --> 
       </button> 
      </div> 
      <div class="concierge-button-container"> 
       <button id="discardWorkflow" class="concierge-button concierge-button-discard button-command tertiary" data-ng-click="discard()"> 
        <span data-ng-bind="getString('discard_workflow_button')" class="ng-binding">Discard</span> 
       </button> 
      </div> 
     </div> 
    </div> 
    <!-- ngIf: showrecent --> 
    <!-- ngIf: showrecent --> 
</div> 

我想點擊文本框以便我可以清除文本。我曾嘗試以下:

describe("New Screen", function() { 
    it("Should give textbox a new name", function() { 

     browser.sleep(10000); 
     console.log('Enter new name'); 
     var editName = element.all(by.className('.workflow-name-textbox')); 

     editName.first().click().then(function() { 
      console.log('Clicked on Create'); 

     }) 
     browser.sleep(10000); 
    }) 

我得到一個錯誤:指數超出界限。試圖在索引來訪問元素:0 ...

如果我改變上述我的代碼: VAR editName = element.all(by.css( '工作流名稱文本框'));

 editName.click().then(function() { 
      console.log('Clicked on Create'); 

我沒有得到錯誤,但我沒有看到任何點擊發生。

我知道我的量角器的工作原理,因爲我使用類似的代碼導航到此頁面。 有沒有人有任何建議我可以嘗試。

回答

1

我不得不走兩頭的iFrame下來:

//Parent 
    browser.switchTo().frame('Iframe1'); 
    //Child 
    browser.switchTo().frame('Iframe2'); 
    //var NewTextBox = browser.findElement(by.css('.name-textbox')).clear(); 
    var NewTextBox = element.all(by.css('.name-textbox')); 
    NewTextBox.clear().then(function() { 

     console.log('Clear text'); 
0

你有沒有嘗試過這種方式,而不是element.all。 element.all返回一個列表elemenet和元素只返回單個元素。

  • var NewTextBox = element(by.css('。workflow-name-textbox'));

  • 變種NewTextBox = 元件(by.xpath( '//輸入[@佔位符=' 輸入工作流名稱 ']'));