我需要点击子标题中的一个按钮点击它将移动到下一个新页面,但是这里我的按钮在测试运行时无法点击
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>
这是我页面的标题 2 我需要单击该按钮并转到下一页我的问题是使该按钮可单击
答案 0 :(得分:1)
我只是添加了一个&#34; id&#34;它现在可以点击并转到下一页
<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();
});
});
});