{"record":{"id":"d514dda7192ad1d9","repo":"SeleniumHQ/selenium","slug":"element-does-not-have-any-client-rects","errorCode":null,"errorMessage":"Element does not have any client rects","messagePattern":"Element does not have any client rects","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/chrome-driver/atoms.js","lineNumber":200,"sourceCode":"  var elemClientPos = goog.style.getClientPosition(elem);\n  return new goog.math.Coordinate(\n      elemClientPos.x + region.left, elemClientPos.y + region.top);\n};\n\n\n/**\n * Returns the first client rect of the given element, relative to the\n * element's border box. If the element does not have any client rects,\n * throws an error.\n *\n * @param {!Element} elem The element to use.\n * @return {!goog.math.Rect} The first client rect of the given element,\n *     relative to the element's border box.\n */\nwebdriver.chrome.getFirstClientRect = function(elem) {\n  var clientRects = elem.getClientRects();\n  if (clientRects.length == 0)\n    throw new Error('Element does not have any client rects');\n  var clientRect = clientRects[0];\n  var clientPos = goog.style.getClientPosition(elem);\n  return new goog.math.Rect(\n      clientRect.left - clientPos.x, clientRect.top - clientPos.y,\n      clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);\n};\n\n\n/**\n * Returns whether the element or any of its descendants would receive a click\n * at the given location. Useful for debugging test clicking issues.\n *\n * @param {!Element} elem The element to use.\n * @param {!goog.math.Coordinate} coord The coordinate to use.\n * @return {{clickable:boolean, message: (string|undefined)}} Object containing\n *     a boolean \"clickable\" property, as to whether it can be clicked, and an\n *     optional \"message\" string property, which contains any warning/error\n *     message.","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/chrome-driver/atoms.js#L182-L218","documentation":"webdriver.chrome.getFirstClientRect in chrome-driver/atoms.js returns the element's first DOMRect from getClientRects(), recomputed relative to the element's border box. If getClientRects() returns an empty list (length 0), it throws this error because there is no rect to normalize — the element has zero rendered geometry. Elements with display:none, an SVG element with no layout, a disconnected/detached element, or an element in a non-rendered <template> all produce an empty client rect list.","triggerScenarios":"Calling getFirstClientRect on an element with display:none or visibility:hidden in some engines. Calling it on a detached element not attached to the document. Calling it on an SVG/foreignObject or <template> content node that has no layout box. Calling it before the element has been laid out (e.g. immediately after insertion in a synchronous script).","commonSituations":"Chrome-driver click/coordinate computation invoked against an element that was hidden or detached between findElement and the action. Race conditions where the element is removed from the DOM (StaleElement) but the rect call still runs. SVG elements that render no box. Elements inside display:none containers.","solutions":["Verify the element is rendered (getComputedStyle(elem).display !== 'none' and document.contains(elem)) before calling getFirstClientRect.","Re-find the element if it may have been detached, then retry.","For SVG/non-HTML elements, use getBoundingClientRect() with a fallback or a different geometry source.","Add a small wait/retry for elements still undergoing layout insertion."],"exampleFix":"// before\nvar rect = webdriver.chrome.getFirstClientRect(elem) // throws if no client rects\n\n// after\nif (document.contains(elem) && elem.getClientRects().length > 0) {\n  var rect = webdriver.chrome.getFirstClientRect(elem)\n} else {\n  // element not laid out; wait or fall back\n}","handlingStrategy":"type-guard","validationCode":"if (!document.contains(elem) || elem.getClientRects().length === 0) {\n  // element not laid out; do not call getFirstClientRect\n  return null\n}","typeGuard":"function hasClientRects(elem) {\n  return !!elem && document.contains(elem) && elem.getClientRects().length > 0\n}","tryCatchPattern":"try {\n  rect = webdriver.chrome.getFirstClientRect(elem)\n} catch (e) {\n  if (/does not have any client rects/.test(e.message)) { /* wait/re-find */ }\n  else throw e\n}","preventionTips":["Verify display !== 'none' and document.contains(elem) before calling.","Re-find elements suspected of being detached/stale.","For SVG/template nodes, use an alternate geometry source.","Allow a brief layout settle after inserting elements."],"tags":["dom","geometry","chrome-driver","atoms","clientrects"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}