我是Protractor的新手,我正在执行一些e2e测试,我在最后一个测试中遇到问题,当我尝试调用下拉列表并选择其中一个选项时.
这是我的代码:
it('filter', function() {
console.log('test log');
var e = document.getElementById('Develop');
var strUser = e.options[e.selectedIndex].value;
e.selectedIndex = 2;
});
Run Code Online (Sandbox Code Playgroud)
在referenceError我得到每次都是:
document is not defined
Run Code Online (Sandbox Code Playgroud)
怎么可能出错?
感谢您的帮助.
在执行特定操作后需要测试类名的更改.在我的应用程序中,按下按钮后,页脚进度条显示进度.
页脚代码中唯一的变化是类名更改.以下是代码段:
之前:
<i class="fa fa-check-circle pull-left" ng-class="{processComplete : sent}"></i>
Run Code Online (Sandbox Code Playgroud)
完成后:
<i class="fa fa-check-circle pull-left processComplete" ng-class="{processComplete : sent}"></i>
Run Code Online (Sandbox Code Playgroud)
如何使用量角器测试类名的变化?
我正在尝试在Windows机器上设置Protractor测试.我已经启动并运行了服务器,但是当我进行测试时,它失败并且我收到以下错误:ReferenceError:modules not defined"
我正在使用PageObject模式来构建我的测试和测试框架.
在我的测试文件中,我有:
describe('Ticket', function(){
var etPage = require('ticket-page.js');
beforeEach(function () {
etPage.get();
});
it('Should set Action', function(){
browser.debugger();
etPage.setTicketId(1);
});
};
Run Code Online (Sandbox Code Playgroud)
并在Ticket-page.js类中
var EquityTicketPage = function () {
this.ticketWrapper = null;
this.setTicketId = function(id){
this.ticketWrapper = driver.element(By.ByCssSelector('[data-ticket-id="' + id + '"]'));
};
this.get = function () {
browser.ignoreSynchronization = true;
browser.get('http://deleted');
};
};
modules.exports = new EquityTicketPage();
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪指向"modules.exports = new EquityTicketPage();" 在tickets-page.js文件中.我不确定它在这条线上的失败.对于这些文件,可能没有正确设置/引用节点.也许它在我的机器上没有正确设置.
我看到了这个问题,并认为配置可能有问题.我的node_modules文件夹中没有grunt-karma版本,我不知道是否需要它.
然后看着这个问题,我想我的配置文件中可能需要一些内容,并注意到我没有文件部分.文件部分指向代码文件所以我应该没问题.
这是我的配置
// A reference configuration …Run Code Online (Sandbox Code Playgroud) 我正在尝试检查是否已选中复选框,如果没有选中它.无论如何,我永远无法检查它,因为它永远不会到达click().请参阅下面的代码.
这是量角器测试中的代码:
//find item
var useSslInput = $('#useSsl');
if(newDirectory.useSsl == true){
if(!useSslInput.isSelected()){
useSslInput.click();
}
var sslInput = $('#sslCertificate');
sslInput.sendKeys(newDirectory.sslCertificate);
} else {
if(!useSslInput.isSelected()){
useSslInput.click();
}
}
Run Code Online (Sandbox Code Playgroud)
html如下:
<div class="field">
<label class="field-label" for="useSsl">{{::'directory.page.add.label.useSsl' |i18n}}</label>
<div class="field-input"><input id="useSsl" name="useSsl" type="checkbox" ng-model="addEditDirectory.directory.useSsl" ng-checked="addEditDirectory.directory.useSsl"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我在这里做错了吗?
我有一个简单的复选框,我想使用量角器(AngularJS)进行检查。
我试过了:
$('.checkbox-class-name').click();
Run Code Online (Sandbox Code Playgroud)
但这无济于事。选择器正在工作(找到我的元素),但单击没有运气。我也尝试过:
it('should test something if checkbox is checked', function (done) {
myPage.navigate();
$('.checkbox-class-name').click().then(function() {
//expect something here
done();
})
});
Run Code Online (Sandbox Code Playgroud)
但这不起作用(它进入“ then”内部,但是如果我暂停浏览器,我会看到未选中该复选框)
我究竟做错了什么?
编辑我的HTML代码:
<div ng-if="vm._getTermsAndConditionsFlag()">
<input class="checkbox-class-name" id="checkbox-name"
ng-model="vm.termsAndConditionsChecked" type="checkbox">
<label for="checkbox-name" >I agree to the terms & conditions</label>
</div>
Run Code Online (Sandbox Code Playgroud) 我知道这里有类似的问题,但是对于我的生活我无法理解它们.
这是一个例子,我需要点击一个按钮并检查网址.
我最初的想法是我会把它写成
element(by.id('button')).click();
expect(browser.getCurrentUrl()).toContain('asyncisconfusing');
Run Code Online (Sandbox Code Playgroud)
我知道期望处理它的承诺但是.click呢?我不应该这样写吗?
element(by.id('button')).click().then(() => {
expect(browser.getCurrentUrl()).toContain('asyncisconfusing')
})
Run Code Online (Sandbox Code Playgroud)
或者是量角器/网络驱动器自动神奇地做这个?
javascript promise selenium-webdriver angularjs-e2e protractor
protractor ×6
javascript ×4
angularjs ×3
checkbox ×1
e2e-testing ×1
node.js ×1
promise ×1
testing ×1