|
robot中这样引用:${headers} Execute Javascript ${CURDIR}/../../../../05.Files/05.Scripts/head_data_RW.js ARGUMENTS a
一、读取页面表单标题
var array_head_row = [];
var array_head = [];
var start = 0;
var end = 0;
var page = arguments[0];
if (page.search("a")!= -1){
var head_loc = "div[class='aui-grid__header-wrapper fixed-left__wrapper'] thead tr th"#此处必须用css路径
start = 3;/*第三列开始*/
end = -1;/*最后一列没有数据*/
}
else if(page.search("b")!= -1){
var head_loc = "..."
}
array_head_row = document.querySelectorAll(head_loc);
len=array_head_row.length+end;
for (var i=start;i<len;i++){
var text = array_head_row[i].textContent;
console.log(text);
array_head.push(text);
}
return array_head;
二、获取页面表单body数据
var array_row=[];
var array_column=[];
var array_data_all=[];
var LEN = 15;
var page = arguments[0];
switch(page)
{
case 'a':
var data_loc = "div[class='aui-grid__body-wrapper fixed-left__wrapper'] tbody tr"
var column_start = 3;/*第三列开始*/
var column_end = -1;/*最后一列没有数据*/
break;
case 'b':
var data_loc = "div[class='aui-grid__body-wrapper fixed-left__wrapper'] tbody tr"
var column_start = 3;
var column_end = -1;
break;
case 'c':
var data_loc = "div[class='erp-entity-table'] tbody tr"
var column_start = 0;
var column_end = 0;
break;
}
array_row = document.querySelectorAll(data_loc);
array_column = array_row[0].children;
column_end = array_column.length+column_end
for (var i=0,len=array_row.length;i<len;i++){
array_column=array_row[i].children;
var array_data=[];
for (var j=column_start;j<=column_end;j++){
text = array_column[j].textContent;
text = text.replaceAll("\n","");#把换行符取代哦
text = text.replaceAll(/(^\s*)|(\s*$)/g,"");#把首尾的空格去掉
if(text.indexOf("}")!=-1){
text_len = text.length;
text = text.substring(text_len-LEN,text_len);
}
console.log(text);
array_data.push(text);
}
array_data_all.push(array_data);
}
return array_data_all;
|
|