getgauge / taiko

A node.js library for testing modern web applications

Home Page:https://taiko.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not compute content quads error is displayed sometimes when working with exists(0,0)

gokultw opened this issue · comments

Describe the bug
Could not compute content quads error is displayed sometimes when working with exists(0,0)

To Reproduce
Below code some time throwing error Could not compute content quads

await text("SOME_TEXT").exists(0,0);

Logs

Error: Could not compute content quads.
    at node_modules/chrome-remote-interface/lib/chrome.js:94:35
    at Chrome._handleMessage (node_modules/chrome-remote-interface/lib/chrome.js:257:17)
    at WebSocket.<anonymous> (node_modules/chrome-remote-interface/lib/chrome.js:235:22)
    at WebSocket.emit (node:events:527:28)
    at Receiver.receiverOnMessage (node_modules/ws/lib/websocket.js:1059:20)
    at Receiver.emit (node:events:527:28)
    at Receiver.dataMessage (node_modules/ws/lib/receiver.js:517:14)
    at node_modules/ws/lib/receiver.js:468:23
    at node_modules/ws/lib/permessage-deflate.js:308:9
    at node_modules/ws/lib/permessage-deflate.js:391:7
    at afterWrite (node:internal/streams/writable:497:5)
    at onwrite (node:internal/streams/writable:477:7)
    at Zlib.cb (node:internal/streams/transform:202:7)
    at Zlib.processCallback (node:zlib:611:8)

Expected behavior
Exists(0,0) should return true or false based on element existence.

Taiko: 1.4.3
OS: MAC Os 12.4
Node.js: v14.19.1
Gauge version: 1.4.3

got this error for .text() method as well.

We run into the same error and I applied a small change to taiko/lib/handlers/domHandler.js that allows the test suite to finish.
We changed the getBoxModel function so that it returns default coordinates.

async function getBoxModel(e) {
  try {
  let result = await dom.getContentQuads({
    objectId: isElement(e) ? e.objectId : e,
  });
  return { model: { border: result.quads[0] } };
  } catch (e) {
    return {model: { border: [0,0, 0,0, 0,0, 0,0]}};
  }
}

I don't know why it happens and for what object and whether it is a bad idea to solve it like this or not. But I can tell that it solves the issue for us.

@saikrishna321, could you please help here?