有谁知道如何以编程方式选择具有属性unselectable="on"
的量角器测试中的元素?
我需要编写一个量角器测试,检查我的ng模型是否正确递增,但由于此属性,我无法选择要点击的箭头。
所以这在我的测试中不起作用:
var arrow = element(by.css('k-icon k-i-arrow-n')); // this should select the up, increment arrow
arrow.click(); // this doesn't work because nothing has been selected.
答案 0 :(得分:2)
您的CSS选择器与元素不匹配,请为类名使用点:
element(by.css('.k-icon.k-i-arrow-n')).click();
您也可以按title
:
element(by.css('span[title="Increase value"]')).click();
工作演示测试(使用this Kendo UI demo page):
describe("Kendo UI numeric field", function () {
beforeEach(function () {
browser.ignoreSynchronization = true;
browser.get("http://demos.telerik.com/kendo-ui/numerictextbox/index");
});
it("should increase numeric currency value", function () {
var container = element.all(by.css(".k-numerictextbox")).first();
var input = container.element(by.id("currency"));
var arrowUp = container.element(by.css('span[title="Increase value"]'));
var times = 5;
input.getAttribute("value").then(function (oldValue) {
for (var i=0; i < times; i++) {
arrowUp.click();
}
expect(input.getAttribute("value")).toEqual((parseInt(oldValue) + times).toString());
});
});
});