Tag: nightwatch.js

如何使用jquery编写nightwatch自定义命令

我有用javascript为nightwatch.js编写的以下自定义命令。 如何将其转换为使用jquery? exports.command = function (classId, indexIfNotZero) { this.browser.execute(function (classId, indexIfNotZero) { if (classId.charAt(0) == ‘.’) { classId = classId.substring(1); } var items = document.getElementsByClassName(classId); if (items.length) { var item = indexIfNotZero ? items[indexIfNotZero] : items[0]; if (item) { item.click(); return true; } } return false; //alert(rxp); }, [classId, indexIfNotZero], function (result) { console.info(result); }); […]

Nightwatch从选择框中选择选项

我正在尝试使用nightwatch.js从选择框中选择一个选项。 我有代码: this.browser.click(‘select[name=”month”]’) .pause(1000) .click(‘option[value=”3″]’) .click(‘select[name=”day”]’) .pause(1000) .click(‘option[value=”6″]’) .click(‘select[name=”year”]’) .pause(1000) .click(‘option[value=”1989″]’); 它会在页面上选择正确的月份,而不是当天。 这是当天选择框的HTML: Day 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 有谁知道为什么它没有选择正确的一天?