Commit b5f638d6 authored by Sven Franck's avatar Sven Franck

test: added verifyAttribute handling

parent 92606298
...@@ -209,12 +209,17 @@ ...@@ -209,12 +209,17 @@
'</tr>' + '</tr>' +
'<tr>' + '<tr>' +
'<td>click</td>' + '<td>click</td>' +
'<td>//a[.="Login"]</td>' + '<td>//a[.="Menu"]</td>' +
'<td></td>' + '<td></td>' +
'</tr>' + '</tr>' +
'<tr>' +
'<td>verifyAttribute</td>' +
'<td>//div[@id="global-panel"]@class</td>' +
'<td>ui-panel-open</td>' +
'</tr>' +
'<tr>' + '<tr>' +
'<td>click</td>' + '<td>click</td>' +
'<td>//h1[.="Networks"]</td>' + '<td>//h1[.="My Account"]</td>' +
'<td></td>' + '<td></td>' +
'</tr>' + '</tr>' +
'<tr>' + '<tr>' +
...@@ -823,7 +828,8 @@ ...@@ -823,7 +828,8 @@
// (6) add extra column for the comments = QUNIT comment // (6) add extra column for the comments = QUNIT comment
// (7) // (7)
var tableToParse, tag, selector, val, ins, find, close_async, i, var tableToParse, tag, selector, val, ins, find, close_async, i,
instruction, madeJS, add, menu_button, testForElement, countDown; instruction, madeJS, add, menu_button, testForElement, countDown,
getParam, test_value;
// parse table into objcet // parse table into objcet
...@@ -831,6 +837,9 @@ ...@@ -831,6 +837,9 @@
$(another_string), $(another_string),
{"ignoreHiddenRows": false {"ignoreHiddenRows": false
}); });
getParam = function(str) {
return str.split("@").pop();
};
// extract selector tag // extract selector tag
tag = function(str) { tag = function(str) {
return str.split("[")[0].replace("//", ""); return str.split("[")[0].replace("//", "");
...@@ -875,6 +884,12 @@ ...@@ -875,6 +884,12 @@
'$.testHelper.countDown(test, ticker);' + '$.testHelper.countDown(test, ticker);' +
'}, 1000);' + '}, 1000);' +
'};' + '};' +
'$.testHelper.testForAttribute = function(element, attr, value) {' +
'var look = $i.find(element).eq(0).attr(attr);' +
'return $.testHelper.countDown(' +
'look.indexOf(value) > -1' +
');' +
'};' +
'$.testHelper.testForElement = function(element) {' + '$.testHelper.testForElement = function(element) {' +
'return $.testHelper.countDown(' + 'return $.testHelper.countDown(' +
'$i.find(element).length > 0' + '$i.find(element).length > 0' +
...@@ -884,7 +899,7 @@ ...@@ -884,7 +899,7 @@
len = tableToParse.length; len = tableToParse.length;
// loop table rows // loop table rows
for (i = 0; i < 8; i += 1) { for (i = 0; i < 9; i += 1) {
instruction = tableToParse[i]; instruction = tableToParse[i];
// parse instructions // parse instructions
...@@ -911,7 +926,28 @@ ...@@ -911,7 +926,28 @@
wrap = selector(ins); wrap = selector(ins);
find = tag(ins) + wrap[0] + val(ins) + wrap[1]; find = tag(ins) + wrap[0] + val(ins) + wrap[1];
madeJS += 'function () {' + madeJS += 'function () {' +
'console.log($("' + find + '"));$("' + find + '").trigger("click");' + '$("' + find + '").trigger("click");' +
'},';
break;
case "verifyAttribute":
ins = instruction.selector;
wrap = selector(ins);
count += 1;
find = (tag(ins) + wrap[0] + val(ins) + wrap[1]).split("@")[0];
test_value = getParam(ins);
madeJS += 'function () {';
switch (test_value) {
case 'class':
madeJS += 'var t = $.testHelper.testForAttribute("' +
find + '", "' + test_value + '", "' + instruction.value +
'");';
break;
}
madeJS += '}, function (t) {' +
'ok(t, "attribute present");' +
'},'; '},';
break; break;
...@@ -929,6 +965,7 @@ ...@@ -929,6 +965,7 @@
} }
} }
if (close_async) { if (close_async) {
madeJS += 'function() {start();} ]) });'; madeJS += 'function() {start();} ]) });';
madeJS = madeJS.replace(/__number__/, count.toString()); madeJS = madeJS.replace(/__number__/, count.toString());
...@@ -936,6 +973,7 @@ ...@@ -936,6 +973,7 @@
count = undefined; count = undefined;
} }
console.log(madeJS)
// inject // inject
add = d.createElement("script"); add = d.createElement("script");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment