Javascript 量角器中的动态变量
如何在ptor中使用全局变量?“窗口”前缀不起作用Javascript 量角器中的动态变量,javascript,selenium,automated-tests,protractor,e2e-testing,Javascript,Selenium,Automated Tests,Protractor,E2e Testing,如何在ptor中使用全局变量?“窗口”前缀不起作用 element(by.id("priceNet")).getText().then(function (getNet) { net = getNet; }); element(by.id("priceVat")).getText().then(function (getVat) { vat = getVat; }); console.log(vat + " " + net); expect(ele
element(by.id("priceNet")).getText().then(function (getNet) {
net = getNet;
});
element(by.id("priceVat")).getText().then(function (getVat) {
vat = getVat;
});
console.log(vat + " " + net);
expect(element(by.id("priceTotal")).getText()).toContain(net + vat);
当我想使用
window.net时
ptor不知道窗口
我希望使用net和vat。问题解决了。这个解决方案有效。(ofc必须解析为Int或Float)
element(by.id("priceNet")).getText().then( function (getNet) {
element(by.id("priceVat")).getText().then( function (getVat) {
expect(element(by.id("priceTotal")).getText()).toContain(getNet + getVat);
})
});