--- id: "21510477-f8be-41d0-97ec-fb6eec78d165" name: "Star Element Discovery" micro_summary: "Locates Gmail star controls by aria-label and requires scrolling them into view before measuring click coordinates." status: "resolved" see_also: [] scope: "How to find star buttons in Gmail. They use aria-label=\"Not starred\" / \"Starred\". Always at x≈370. Y varies by thread position. Requires scrollIntoView before getBoundingClientRect for off-screen rows." warnings: "Always call scrollIntoView() before getBoundingClientRect(). Negative Y means off-screen above viewport — clicking there will miss." --- ## Selector Star buttons are `` (or `aria-label="Starred"` after clicking). Find them: ```javascript document.querySelectorAll("*").filter(el => el.getAttribute("aria-label") === "Not starred") ``` ## Position Pattern - X is always ~370 (left column, star column) - Y varies by thread position in the inbox - After starring, the element's aria-label changes to "Starred" and it disappears from the "Not starred" query ## Key Detail Use `getBoundingClientRect()` AFTER `scrollIntoView()`. Negative Y from `getBoundingClientRect()` means the element is above the viewport — scroll it into view first. ```python js('document.querySelector(\'[aria-label="Not starred"]\').scrollIntoView({block: "center"})') time.sleep(0.3) # wait for scroll # now getBoundingClientRect gives viewport-relative coords ```