From 824094830cc024406e6aaa53ff99e3eb810070bb Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 31 Aug 2017 18:16:06 +0530 Subject: [PATCH] [Enhance] selector by class name in for UI test cases (#4022) --- frappe/public/js/frappe/misc/test_utils.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frappe/public/js/frappe/misc/test_utils.js b/frappe/public/js/frappe/misc/test_utils.js index 67b97353d2..73fdfc8f89 100644 --- a/frappe/public/js/frappe/misc/test_utils.js +++ b/frappe/public/js/frappe/misc/test_utils.js @@ -22,6 +22,16 @@ frappe.click_link = function(text, idx) { return frappe.timeout(0.5); }; +frappe.click_element = function(selector, idx) { + // Selector by class name like $(`.cart-items`) + let element = $(`${selector}`); + if(!element.length) { + throw `did not find any link containing ${selector}`; + } + element.get(idx || 0).click(); + return frappe.timeout(0.5); +}; + frappe.set_control= function(fieldname, value) { let control = $(`.form-control[data-fieldname="${fieldname}"]:visible`); if(!control.length) {