我的量角器脚本没有在下一页上拾取元素。它在第一页(填写客户详细信息)上运行测试。点击重定向后,cmd会触发;
失败:找不到使用定位器的元素:by.model(" formData.card_no")
是因为角度未加载还是我必须注入$scope
。
我是量角器的新手。在驱动程序上尝试了各种waits
和sleeps
..加上ignoreSynchronisation
..没有。
但是,当我手动将生成的ID放在付款详细信息的末尾时, url,它获取所有元素并传递所有测试。
所以问题必须是从后端获取卖家生成的交易ID以继续测试。不确定它在Protractor中是如何完成的。
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
pecs: ['../test/*spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutOutInterval: 30000
}
};
待办事项-spec.js
var util = require ('util');
describe('angularjs homepage todo list', function() {
browser.get('https://xxx');
element(by.css('.start-btn')).click();
var seller_details = require('../page/seller_details.js');
it ('should be bla bla bla', function(){
seller_details.enterFormName();
seller_details.enterFormCell();
seller_details.enterFormEmail();
seller_details.enterFormVR();
seller_details.enterFormVV();
seller_details.checkFormNotStolen();
seller_details.clickStart();
//after redirecting to payment details page
payment_details.enterCardNo();
payment_details.enterCardHolder();
payment_details.enterExpiryMonth();
payment_details.enterExpiryYear();
payment_details.enterCVV();
});
});
seller_details.js (页面对象)
require ('../page/payment_details.js')
var seller_details = function(){
this.enterFormName = function(value){
element(by.model('formData.name')).sendKeys('ron');
};
this.enterFormCell = function(value){
element(by.model('formData.cell')).sendKeys('0734555543');
};
this.enterFormEmail = function(value){
element(by.model('formData.email')).sendKeys('ron@sqw.com');
};
this.enterFormVR = function(value){
element(by.model('formData.veh_reg')).sendKeys('ND 3491');
};
this.enterFormVV = function(value){
element(by.model('formData.veh_vin')).sendKeys('13ADFPORT4QP9CR5L');
};
this.checkFormNotStolen = function(){
element(by.model('formData.not_stolen')).isSelected();
};
this.clickStart = function(){
element(by.css('.spinner-btn')).click();
return require('./payment_details.js');
};
};
module.exports = new seller_details();
payment-details.js (另一个页面对象)
var payment_details = function(){
this.enterCardNo = function(value){
element(by.model('formData.card_no')).sendKeys('4111111111111111');
};
this.enterCardHolder = function(value){
element(by.model('formData.card_holder')).sendKeys('yayayay');
};
this.enterExpiryMonth = function(value){
element(by.model('formData.expiry_month')).sendKeys('12');
};
this.enterExpiryYear = function(value){
element(by.model('formData.expiry_year')).sendKeys('2019');
};
this.enterCVV = function(value){
element(by.model('formData.cvv')).sendKeys('123');
};
this.clickBtn = function(value){
element(by.css('.spinner-btn')).click();
};
};
module.exports = new payment_details();
提前感谢您提供的任何帮助。如果您需要具有controller.js
的{{1}},请与我们联系。