2015-10-15 138 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(); 
        }); 
       }); 
      });