Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use the interaction layer the map actually exposes. If the drawn feature is an HTML or SVG node, call Puppeteer’s page.click(selector) with a stable selector. If a mapping library owns the shape, trigger its feature object or event through the application’s supported API. If the map is only a canvas or rendered surface, calculate a page-specific screen coordinate and send mouse input. There is no universal selector or coordinate that works for every map, so inspect the target page before writing the test.

Choose the right access method first

A map can display the same polygon, line or circle through very different implementations. Your automation strategy depends on which of these representations exists:

What you find in the page Preferred Puppeteer strategy Main trade-off
HTML control or SVG element with a stable attribute Locate it with a selector and use page.click(selector) Simple and close to a user click, but only works when the feature is exposed as a DOM node
Mapping-library overlay or feature object Use the library’s feature model, event, or application command Usually more deterministic, but couples the test to that library or app architecture
Canvas, WebGL, or another rendered surface with no useful node Compute a coordinate in the rendered map and call page.mouse.click(x, y) Layout, zoom, pan and viewport changes can invalidate coordinates

Puppeteer is a high-level API for controlling Chrome or Firefox. Its page click API is designed for selectors, not geographic identities. Google Maps JavaScript API is a useful example of the other model: polygons, polylines, circles and rectangles are overlays associated with latitude/longitude coordinates, and the shape can expose its own events. Do not assume an unspecified target uses Google Maps; verify the actual library and rendering mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect the map before writing a click

Check the DOM and accessibility tree

Open DevTools while the map is visible. Select the apparent feature and see whether the inspector highlights an element. Look for an SVG path, a button that controls a selected region, or a wrapper with a stable data-* attribute. Avoid generated class names, pixel coordinates copied from one screenshot, and selectors tied to framework internals.

#1 Best Overall
Sale
Garmin Drive™ 53 GPS Navigator
  • Bright, high-resolution 5” glass capacitive touchscreen display lets you easily view your route
  • Get more situational awareness with alerts for school zones, speed changes, sharp curves and more
  • View food, fuel and rest areas along your active route, and see upcoming cities and milestones
  • View Tripadvisor traveler ratings for top-rated restaurants, hotels and attractions to help you make the most of road trips
  • Directory of U.S. national parks simplifies navigation to entrances, visitor centers and landmarks within the parks

Also inspect the page source and runtime accessibility tree. A visible polygon may have no corresponding accessible node, while a nearby “Select region” control may be the supported user-facing interface. If the feature is not represented in either place, continue to the map library or coordinate approach.

Identify the mapping library and drawing mode

Network requests, script URLs and global objects can reveal whether the page uses Google Maps JavaScript API, another mapping package, SVG, canvas or WebGL. In an application you control, expose a test-friendly command or stable feature identifier rather than forcing tests to reverse-engineer pixels.

For Google Maps, the official documentation describes map shapes as overlays. Polygon options include mouse-event handling, and polygons can receive a click event. The Drawing Library reference also states that ordinary map click and mousemove events are temporarily disabled while drawing is active; completion events such as polygoncomplete and overlaycomplete are the appropriate hooks for that phase. Google labels the Drawing Library functionality deprecated, so check the target application’s current implementation before building new automation around it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Click a DOM or SVG feature with Puppeteer

When the drawn feature is a real element, use a selector that expresses its identity. The documented behavior of page.click(selector) is to find the matching element, scroll it into view when necessary, and click its center. It throws when no element matches.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.setViewport({width: 1440, height: 900, deviceScaleFactor: 1});
await page.goto('https://example.com/map', {waitUntil: 'networkidle2'});

const feature = '[data-feature-id="park-42"]';
await page.waitForSelector(feature, {visible: true, timeout: 15000});
await page.click(feature);

await page.waitForSelector('[data-testid="feature-details"]', {visible: true});
console.log(await page.$eval('[data-testid="feature-details"]', el => el.textContent));
await browser.close();

Replace the example URL and attributes with selectors confirmed on your page. Waiting for the feature is important on maps that render asynchronously. If the selector matches several nodes, make it unique or use an explicit locator strategy and verify the count before clicking.

Rank #2
Sale
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
  • 6” high-resolution navigator includes map updates of North America
  • Hands-free calling when paired with your compatible smartphone with BLUETOOTH technology and convenient Garmin voice assist lets you ask for directions to places you want to go
  • Road trip–ready features include the HISTORY database of notable sites, a U.S. national parks directory, Tripadvisor traveler ratings and millions of Foursquare POIs
  • Driver alerts for things such as school zones, sharp curves and speed changes help encourage safer driving and increase situational awareness
  • Access live traffic, fuel prices, parking, weather and smart notifications when you pair this navigator with your compatible smartphone running the Garmin Drive app

When the visible shape is SVG

SVG paths can be clicked like other DOM nodes when pointer events are enabled. A selector such as svg path[data-feature-id="park-42"] is preferable to a class generated by a build tool. If the path is covered by another layer, inspect stacking order and pointer-event CSS; clicking the path’s center may not represent a point inside the intended geometry.

When a control represents the geometry

Some applications draw geometry for display but expose selection through a list, search result, or keyboard-accessible control. Clicking that control is usually more stable than clicking the pixels. Assert the resulting state (selected ID, details panel, URL or emitted application event) rather than relying only on a screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the map library’s feature model when it is available

A library-managed overlay may not appear as a meaningful DOM element. In that case, interact through the application code that owns the feature. For example, a Google Maps polygon can be configured with a shape-level click listener. A testable application can keep a reference to the polygon, expose a command that selects it by business ID, or translate the event into application state.

// Application-side pattern, not a universal Puppeteer selector
const polygon = new google.maps.Polygon({
  paths: regionCoordinates,
  clickable: true,
  map
});
polygon.addListener('click', () => {
  selectRegion('park-42');
});

From Puppeteer, drive the same supported UI or test hook that a user would use, then assert selectRegion’s visible result. If your test architecture permits browser-context evaluation, call only a deliberately exposed application function; do not depend on private, minified library internals that can change between releases.

Drawing mode needs a separate test branch

While a drawing tool is active, the map may reserve pointer events for creating the shape. A click intended to select an existing polygon can therefore be ignored or interpreted as another vertex. Complete or cancel drawing first, wait for the application’s drawing-state indicator to change, and only then select the finished feature. For Google’s documented drawing events, capture the completed overlay and its application ID, then test selection in a normal interaction state.

Rank #3
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
  • Explore confidently with the reliable handheld GPS
  • 2.2” sunlight-readable color display with 240 x 320 display pixels for improved readability
  • Preloaded with Topo Active maps with routable roads and trails for cycling and hiking
  • Support for GPS and GLONASS satellite systems allows for tracking in more challenging environments than GPS alone
  • 8 GB of internal memory for map downloads plus a micro SD card slot

Click a canvas or rendered map by coordinate

If inspection finds no useful node or feature hook, use screen coordinates. The coordinate must be computed from the actual rendered map and geometry, not copied from a fixed screenshot. Control the viewport, wait for the map to settle, and ensure the target feature is visible after any pan or zoom.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.setViewport({width: 1280, height: 800, deviceScaleFactor: 1});
await page.goto('https://example.com/map', {waitUntil: 'networkidle2'});
await page.waitForSelector('#map', {visible: true});

// Replace these values with coordinates calculated for this page and state.
const point = {x: 642, y: 376};
await page.mouse.click(point.x, point.y, {button: 'left', clickCount: 1});
await page.waitForSelector('[data-testid="feature-details"]', {visible: true});

await browser.close();

The page-mouse API sends input in viewport coordinates. Map center, zoom, pan, browser scale, responsive layout, sidebars and consent dialogs all affect the correct point. Recompute the point after each state change that can move the map, and validate the click by asserting a visible result.

Make coordinate tests less fragile

  • Set a fixed viewport and device scale factor for the test.
  • Dismiss overlays before measuring the map; a cookie dialog can shift every coordinate.
  • Wait for the map container and for the application’s “tiles ready” or equivalent state.
  • Use known geographic anchors when the library exposes a projection from latitude/longitude to pixels.
  • Take a diagnostic screenshot and log the map bounding box when a coordinate test fails.
  • Keep the map center and zoom deterministic; avoid tests that depend on a user’s saved map state.

A complete decision workflow

  1. Load deterministically. Set the viewport, navigate with an appropriate wait condition, and wait for the map container and feature data.
  2. Classify the feature. Decide whether it is DOM/SVG, library-managed, or canvas/WebGL only.
  3. Select the least-coupled interaction. Prefer a stable visible control, then a supported feature event or application command, and use coordinates only when no better hook exists.
  4. Synchronize state. Ensure consent dialogs, drawing mode, loading indicators and animations cannot intercept the click.
  5. Perform the action. Use page.click for an element or page.mouse.click for a validated coordinate.
  6. Assert outcome, not mechanics. Check the selected feature ID, details panel, URL, network-side effect or other application result.
  7. Capture diagnostics on failure. Save a screenshot, console messages, viewport dimensions and relevant DOM or map-state data.

Troubleshooting common failures

“No element found for selector”

The feature may render later, use a different attribute, or not be a DOM node at all. Confirm the selector in the same navigation state, wait for the data-driven render, and reclassify the feature before switching to coordinates.

The click runs but nothing is selected

Another layer may cover the target, the polygon may have pointer events disabled, or the map may still be in drawing mode. Check overlays and CSS, wait for drawing completion, and assert that the target library’s clickable option or application handler is enabled.

The coordinate works locally but fails in CI

Compare viewport size, device scale factor, browser version, font loading, map center, zoom and responsive breakpoints. Remove nondeterministic saved state and calculate coordinates from the current map bounds instead of hard-coding a screenshot position.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
  • 8” navigator with high-resolution, dual-orientation display and map updates of North America .Special Feature:Large Display; Voice Assist; Hands-Free Calling; Live Traffic and Weather; Traffic Cams and Parking; Smart Notifications,Driver Alerts; Tripadvisor; National Parks Directory; Find Places by Name; Garmin Real Directions Feature.
  • Hands-free calling when paired with your compatible smartphone with BLUETOOTH technology and convenient Garmin voice assist lets you ask for directions to places you want to go
  • Road trip–ready features include the HISTORY database of notable sites, a U.S. national parks directory, Tripadvisor traveler ratings and millions of Foursquare POIs
  • Driver alerts for things such as school zones, sharp curves and speed changes help encourage safer driving and increase situational awareness
  • Access live traffic, fuel prices, weather, parking and smart notifications when you pair this navigator with your compatible smartphone running the Garmin Drive app

Clicks are intercepted by cookie or chat UI

Dismiss the consent or chat element through the same user-visible flow, or configure your test environment so it does not appear. Do not hide an obstruction and then claim that the map interaction was tested if a real user would still be blocked.

Google drawing events never fire

Verify whether drawing is active and whether the application still uses the deprecated Drawing Library. During drawing, ordinary map click and mousemove events are disabled; listen for the documented completion event and test post-drawing selection separately.

Reliability, speed and maintenance

  • Reliability: DOM selectors and application-level feature IDs generally survive viewport changes better than pixel coordinates, but only if the application treats them as stable contracts.
  • Speed: Avoid arbitrary long delays. Wait for a specific selector, application state or network-idle condition, then act immediately.
  • Isolation: Use a fresh page or context when map state, cookies or geolocation can leak between tests.
  • Maintenance: Keep selectors and exposed test hooks documented with the feature’s business ID. Revisit coordinate calculations whenever map layout or projection changes.
  • Evidence: On failure, retain the screenshot and state needed to distinguish a bad selector, a blocked pointer event, a stale coordinate and a failed map load.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a clean visual capture rather than interaction with a specific drawn feature, ScreenshotNeo returns a screenshot or PDF from one request. It removes cookie and consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for all options, including full-page lazy-image loading, CSS-selector element capture, custom JavaScript and CSS, waits, request blocking, cookies and headers, device presets, PDFs, signed links, asynchronous jobs, bulk capture and caching.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account.

FAQ

Can Puppeteer click a polygon by latitude and longitude?

Not directly. Latitude and longitude identify geometry in a mapping library; Puppeteer needs a DOM target, an application-level event or a screen coordinate produced by the page’s current projection.

Best Value
Sale
Garmin Drive™ 53 GPS Navigator, High-Resolution Touchscreen, Simple On-Screen Menus and Easy-to-See Maps, Driver Alerts (Renewed)
  • Bright, high-resolution 5” glass capacitive touchscreen display lets you easily view your route
  • Get more situational awareness with alerts for school zones, speed changes, sharp curves and more
  • View food, fuel and rest areas along your active route, and see upcoming cities and milestones
  • View Tripadvisor traveler ratings for top-rated restaurants, hotels and attractions to help you make the most of road trips
  • Directory of U.S. national parks simplifies navigation to entrances, visitor centers and landmarks within the parks

Should I use a screenshot to find the click point?

A screenshot can help diagnose alignment, but it does not provide a cross-library hit-testing method. Derive and validate the point from the live map state, then assert the application result.

Is Google’s Drawing Library a good basis for new tests?

Its documentation marks the Drawing Library functionality deprecated. If the target still uses it, test its documented completion and shape events; for new application work, confirm the currently supported mapping implementation first.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can Puppeteer click a polygon by latitude and longitude?

Not directly. Latitude and longitude identify geometry in a mapping library; Puppeteer needs a DOM target, an application-level event or a screen coordinate produced by the page’s current projection.

Should I use a screenshot to find the click point?

A screenshot can help diagnose alignment, but it does not provide a cross-library hit-testing method. Derive and validate the point from the live map state, then assert the application result.

Is Google’s Drawing Library a good basis for new tests?

Its documentation marks the Drawing Library functionality deprecated. If the target still uses it, test its documented completion and shape events; for new application work, confirm the currently supported mapping implementation first.

Quick Recap

SaleBestseller No. 1
Garmin Drive™ 53 GPS Navigator
Garmin Drive™ 53 GPS Navigator
Includes detailed map updates of the North America
$99.99
SaleBestseller No. 2
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
6” high-resolution navigator includes map updates of North America; Built-in Wi-Fi connectivity allows easy map and software updates without a computer
$215.99
Bestseller No. 3
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
Explore confidently with the reliable handheld GPS; Preloaded with Topo Active maps with routable roads and trails for cycling and hiking
$199.99
SaleBestseller No. 4
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Built-in Wi-Fi connectivity allows easy map and software updates without a computer
$289.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.