2015-10-15 186 views
2

我需要點擊一下,它移動到下一個新的一頁子標題按鈕,但這裏同時測試運行按鈕無法點擊

var quotationList, 
     leadListElems, 
     createQuotationButton, 
     quotationCreateCount, 
     leadNameTittle, 
     ionList; 

     beforeEach(function() { 
      leadListElems   = element.all(by.css('ion-item.item.item-stable')); 
      quotationList   = element(by.css('.list')); 
      createQuotationButton = element.all(by.css('.button .button-clear')); 
      quotationCreateCount = element.all(by.css('.title .ng-binding .title-left')); 
      leadNameTittle   = element(by.css('.title .nav-bar-title .ng-binding')); 
      ionList     = element(by.css('.scroll-content .ionic-scroll .has-subheader')); 
     }); 

    it('should create a new Quotation',function(){ 
     leadListElems.get(5).click().then(function(){ 
      expect(browser.getLocationAbsUrl()).toMatch('/lead/details/5'); 
      browser.executeScript('window.scrollTo(0,0);'); 
       createQuotationButton.click().then(function(){ 
        expect(browser.getLocationAbsUrl()).toMatch('/details/5/quotation/create/'); 
        expect(leadNameTittle.getAttribute('value')).toContain('1'); 
        expect(ionList.getAttribute('value')).toContain('');  
        browser.sleep(5000); 
       browser.navigate().back(); 
       }); 
      }); 
     }); 

createQuotationButton我的按鈕無法點擊無法點擊而測試運行 我該按鈕的HTML看起來像這樣

<a class="button button-clear" ng-show="!userService.isOffline" style="width: 20px; float: right; margin-bottom: -10px" ng-click="onQuotCreate()"> 
      <i class="icon ion-plus-circled" style="font-size: 40px;"></i> 
     </a> 

這是我該網頁我需要點擊該按鈕,並移動到下一個頁面我的問題是使按鈕clickab的頭樂

+0

這怎麼不能點擊?它是否可見?你可以點擊它,但沒有任何反應?你是否在JavaScript控制檯窗口中遇到任何異常?發生了什麼,你期望發生什麼? – Patrick

+0

該按鈕應該被點擊並且它應該移動到這個頁面並且看它的標題以匹配一個值,但是這個過程在按鈕點擊時停止並且設置err「Expected'/ lead/details/5 /'以匹配'/ details/5 /報價/創建/」「。 「NoSuchElementError:沒有找到使用locator的元素:By.cssSelector(」。title .nav-bar-title .ng-binding「)」 –

+0

它是可見的我可以手動點擊它,但我無法通過測試用例程序點擊它 –

回答

1

我只是增加了一個「身份證」,以它現在是可以點擊的,它移動到下一個頁面

<a class="button button-clear" id="myId" ng-show="!userService.isOffline" style="width: 20px; float: right; margin-bottom: -10px" ng-click="onQuotCreate()"> 
      <i class="icon ion-plus-circled" style="font-size: 40px;"></i> 
     </a> 



var quotationList, 
      leadListElems, 
      createQuotationButton, 
      quotationCreateCount, 
      leadNameTittle, 
      ionList; 

      beforeEach(function() { 
       leadListElems   = element.all(by.css('ion-item.item.item-stable')); 
       quotationList   = element(by.css('.list')); 
       createQuotationButton = element(by.id('myId')); 
       quotationCreateCount = element.all(by.css('.title .ng-binding .title-left')); 
       leadNameTittle   = element(by.css('.title .nav-bar-title .ng-binding')); 
       ionList     = element(by.css('.scroll-content .ionic-scroll .has-subheader')); 
      }); 

     it('should create a new Quotation',function(){ 
      leadListElems.get(5).click().then(function(){ 
       expect(browser.getLocationAbsUrl()).toMatch('/lead/details/5'); 
       browser.executeScript('window.scrollTo(0,0);'); 
        createQuotationButton.click().then(function(){ 
         expect(browser.getLocationAbsUrl()).toMatch('/details/5/quotation/create/'); 
         expect(leadNameTittle.getAttribute('value')).toContain('1'); 
         expect(ionList.getAttribute('value')).toContain('');  
         browser.sleep(5000); 
        browser.navigate().back(); 
        }); 
       }); 
      });