Commit 07480c73 by 高源

table函数getData方法获取表全部数据

parent 2f5b0346
......@@ -85,6 +85,7 @@ export default {
_table.newCell(_this.Xpaths[i])
}
_table.verify()
_table.getData()
console.log(_table)
// console.log(_this.table)
//----------------------
......
......@@ -39,7 +39,7 @@ function table () {
} else { break; }//如果发现不同的,直接就可以退出了
}
}
console.log(tableXpath)
if (tableXpath.length < 1) return _isVerified;//如果没有共同父节点,返回false
while (tableXpath.length > 0) {
......@@ -59,6 +59,21 @@ function table () {
*/
this.getData = function () {
if (!_isVerified) return null;//如果还没通过验证不返回数据
console.log(this.cells)
let relativeXpaths = []
for (let i = 0; i < this.cells.length; i++) {
relativeXpaths.push(this.cells[i].relativePath)
}
// 找出的全部xpath信息
let resultElement = combineXPaths(this.cells[0]._tableXpathArray, relativeXpaths);
let xpaths = [] // 当前表的全部xpath
console.log(resultElement)
for (let i = 0; i < resultElement.length; i++) {
for (let k = 0; k < resultElement[i].paths.length; k++) {
xpaths.push(resultElement[i].paths[k])
}
}
console.log(xpaths)
}
}
/**
......@@ -99,7 +114,7 @@ function cell (xpath, name = "", type = "", title = "") {
this.updateRelativePath = function (parentXpath) {
this._tableXpathArray = parentXpath;//其实这边严谨的来说要验证一下XPath是否真的有相同的根
this._relativeXpathArray = _xpathArray.slice(this._tableXpathArray.length);
// this.relativeXpath = _relativeXpathArray
// this.relativeXpath = this._relativeXpathArray
// this.tableXpath = _tableXpathArray
// console.log(this._relativeXpathArray)
}
......@@ -108,7 +123,7 @@ function cell (xpath, name = "", type = "", title = "") {
* @returns {boolean}
*/
this.isExist = function (cell) {
console.log(cell)
let existCount = 0;
let _tableXpathArray = [...cell._tableXpathArray] //深拷贝,值修改不影响原数组
let _relativeXpathArray = [...cell._relativeXpathArray]//深拷贝,值修改不影响原数组
......@@ -118,14 +133,11 @@ function cell (xpath, name = "", type = "", title = "") {
let lastElementWithoutIndex = lastElement.split('[')[0];
_tableXpathArray[_tableXpathArray.length - 1] = lastElementWithoutIndex;
}
_tableXpathArray = _tableXpathArray.join('/')
_relativeXpathArray = _relativeXpathArray.join('/')
//table[0]+relativeXpath,可以不存在,因为可能是表头,1,2
for (let i = 0; i < 3; i++) {
let isGetElement = elementExists(_tableXpathArray + '[' + (i + 1) + ']' + '/' + _relativeXpathArray)
console.log(isGetElement)
if (isGetElement) {
existCount = i
} else {
......@@ -311,7 +323,7 @@ function combineXPaths (commonXPath, paths) {
// 然后去除公共路径最后一个元素的下标
// let samePath =''
let commonPath = [];
commonPath = commonXPath
commonPath = [...commonXPath]
if (commonPath.length > 0) {
let lastElement = commonPath[commonPath.length - 1];
let lastElementWithoutIndex = lastElement.split('[')[0];
......
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