这是我的代码。如果我输入S字母,它会显示3个结果,我只想选择一个值。有人可以帮助我如何使用Cucumber步骤定义只选择一个值。
function editRow(obj) {
var currentTD = obj.parentNode.parentNode.rowIndex;
var table = document.getElementById("myTableData");
var row_length = document.getElementById("myTableData").rows[currentTD].cells.length;
console.log(obj.parentNode);
//the below is a way to get the HMTL within a cell
console.log(document.getElementById("myTableData").rows[currentTD].cells[0].innerHTML);
if (obj.value == 'Edit') {
document.getElementById("myTableData").rows[currentTD].cells[0].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].cells[1].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].cells[2].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].cells[3].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].cells[4].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].cells[5].setAttribute("contentEditable", true);
document.getElementById("myTableData").rows[currentTD].style.backgroundColor = "#A4D9F5";
var_employeetype = document.getElementById("myTableData").rows[currentTD].cells[0].innerHTML
var_daysworked = document.getElementById("myTableData").rows[currentTD].cells[1].innerHTML
var_num_employees = document.getElementById("myTableData").rows[currentTD].cells[2].innerHTML
var_shift_start = document.getElementById("myTableData").rows[currentTD].cells[3].innerHTML
var_shift_start = document.getElementById("myTableData").rows[currentTD].cells[4].innerHTML
var_shift_end = document.getElementById("myTableData").rows[currentTD].cells[5].innerHTML
console.log(var_employeetype)
obj.value = 'Save'
} else {
document.getElementById("myTableData").rows[currentTD].cells[0].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].cells[1].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].cells[2].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].cells[3].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].cells[4].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].cells[5].setAttribute("contentEditable", false);
document.getElementById("myTableData").rows[currentTD].style.backgroundColor = "#FFFFFF"
obj.value = 'Edit'
location.href = '/people/updateshift'
}
}
答案 0 :(得分:0)
假设您正在使用带黄瓜的水豚并假设您知道如何从步骤定义调用辅助方法并且您的选择框具有ID
module FormSH
def select_second_option(id)
second_option_xpath = "//*[@id='#{id}']/option[2]"
second_option = find(:xpath, second_option_xpath).text
select(second_option, :from => id)
end
end
World FormSH
然后从你的步骤def
select_second_option('RportName')
应该足以让你前进。