Free tools Windows power users keep installed

One-click scans. No signup required.

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

Use a stable selector, read the displayed text with .invoke('text'), normalize only known formatting characters, convert the result to a number, and assert it in the same Cypress chain. For an input, read its value with .invoke('val') instead. Keeping the assertion retryable helps when an odometer updates asynchronously.

Read the odometer text and convert it

DOM text is a string, even when it looks numeric. Select the component, retrieve its text, normalize the display, and convert it before making a numeric assertion. Prefer a dedicated data-cy or data-test attribute so a styling or copy change is less likely to break the test; Cypress recommends data attributes for stable selectors (Cypress selector best practices).

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => {
    // This example assumes commas are thousands separators,
    // and that the value may contain whitespace or a unit label.
    const normalized = raw.replace(/[^d.-]/g, '')
    return Number(normalized)
  })
  .should('be.a', 'number')
  .and('eq', 12345)

.invoke() calls a method on the yielded subject and yields that method’s return value; Cypress supports jQuery methods such as text, attr, and val (Cypress invoke). The conversion step returns a JavaScript number, so the following assertion checks a number rather than comparing text.

Choose the conversion that matches the display

  • Use Number(value) when the cleaned string should represent the whole value. It does not silently accept a numeric prefix followed by unexpected text.
  • Use parseInt(value, 10) for a whole-number display. It discards any fractional portion.
  • Use parseFloat(value) or Number(value) when fractional digits matter. Cypress’s numeric parsing recipe calls out that parseInt loses the fraction (Cypress FAQ).

Do not apply the sample regular expression blindly to every locale. It strips all characters except digits, periods, and minus signs. That is suitable only when commas are known grouping marks and periods are decimal marks. If the display uses a comma as the decimal mark, parse according to that locale instead; indiscriminately removing commas changes the value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Kingneed Truck GPS Speedometer 6.2 inch Extend Digital Display Vehicle Odometer Trip Meter Course Overspeed Alarm MPH/KMH
  • 【MULTI-FUNCTIONS】 This GPS speedometer HUD not only displays the vehicle's driving speed in time, but also dispalys Single Driving Time, Single Driving mileage, Total driving mileage, Altitude and Local Time. Let you know the key informations for your trip.
  • 【BIGGER SIZE SCREEN】 6.2 inch big screen size display make more easily and comfortable to read. Big and green color fonts, green light will let the driver more compfortable and protect the drivers' eyes, specially for long distance driving.
  • 【ALARM FUNCTION】 With Over Speed Alarm and Fatigue Driving Alarm function. Make your driving more safety.
  • 【UNIVERSAL FOR ALL VEHICLE】Collecting speed from GPS satellites. No relation with the car engine, therefore, it's 100% compatible for all vehicles include car, truck, pick-up, suv, scooter, train, motorcycle, bike, boat..
  • 【EASY TO INSTALL & USE】 Easy Setup--Plug & Play- Power through Vehicle Cigarette Outlet Jack. No professional installation is required.

Handle formatting, decimals, labels, and signs

Decimal display

For a decimal odometer, preserve the decimal mark and use a tolerance if the expected value is subject to floating-point representation:

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => Number(raw.replace(/[^d.-]/g, '')))
  .should('be.closeTo', 1234.5, 0.01)

The tolerance above is an example for a value expected around 1234.5; choose one that reflects the application’s intended precision. Do not use parseInt here, because it would turn a display such as 1234.5 into 1234.

Text that includes a label or unit

If the element reads, for example, “Mileage: 12,345 km,” isolate the numeric substring rather than expecting the entire text to convert. Cypress’s parsing guidance demonstrates extracting a numeric portion with slicing or a regular expression (Cypress FAQ).

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .invoke('match', /-?d+(?:[.,]d+)?/)
  .its('0')
  .then((value) => Number(value.replace(',', '')))
  .should('eq', 12345)

This regular expression accepts an optional minus sign and one decimal separator. The final replacement assumes a comma is a grouping mark, not a decimal mark. Adapt both the expression and normalization to the formats the application actually renders; otherwise a test may pass with a misinterpreted number.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
SinoTrack Digital GPS Speedometer Universal Heads Up Display for Car 5.5 inch Large LCD Display HUD with MPH Speed Fatigued Driving Alert Overspeed Alarm Trip Meter for All Vehicle
  • GPS Speedometer Display: Extra large 5.5 inch screen can display the most important MPH data and driving time/mileage/time/direction at the same time, two scales show the speed and the number of satellites respectively, the compass in the middle gives you the direction, satisfying all your data needs during the driving process
  • Driving Safety Alert: What is the most important thing about driving? As we all know, life safety is the first, speeding and fatigued driving are not allowed, our car overspeed alarm HUD has two important reminders, speeding alert and fatigue driving alert, when the speed exceeds your set value, it will emit a ticking sound to remind you so as to reduce the speed; driving time over 4 hours will remind you to need a short break, a caring safety butler during the journey
  • HD Data Display: Equipped with an automatic light-sensitive screen, no need to adjust manually, it will automatically adjust the most suitable display brightness according to the external light, whether in the daytime or at night you can get the clearest data, no longer worry about the problem of not being able to see the display when the sun is strong
  • Technology Processing Chip: SinoTrack digital GPS speedometer hud build-in the chip super performance and compatibility, dual-running memory, and dual-core processor to ensure smooth high-speed operation which offers the data to help your car travel life, effectively reducing the problem of data delay, real-time follow up driving speed
  • Easy to Use& Warranty: One key operation, press for 2 seconds to enter the setting menu, short press to switch the display mode, left to switch the speed and driving direction angle, right to switch the time, number of satellites, driving distance, driving time, etc.

Negative values and empty text

Keep a minus sign only if negative readings are valid. If the value is blank or the selector has no numeric content, Number('') evaluates to zero after normalization can produce an empty string. Guard against that case when zero is a meaningful result:

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => {
    const match = raw.match(/-?d+(?:.d+)?/)
    expect(match, 'numeric odometer text').not.to.be.null
    return Number(match[0])
  })
  .should('eq', 12345)

This example intentionally treats a period as the decimal mark. Change it if the application uses a different format.

Read input values, attributes, or accessible text correctly

Input-backed odometer

For an input element, read its current value with .invoke('val'); text() reads element text and is not the right way to retrieve an input’s value. Input values are still strings, so convert them before numeric assertions. Cypress demonstrates the val-then-Number pattern in its examples (Cypress invoke).

cy.get('[data-cy="odometer"]')
  .invoke('val')
  .then(Number)
  .should('eq', 12345)

Value stored in an attribute or accessibility representation

If the application intentionally exposes the canonical value in an attribute, retrieve that attribute with .invoke('attr', 'aria-valuenow') or the relevant attribute name, then convert it. An accessible text node or a purpose-built value attribute can be more reliable than parsing decorative animation markup. Use the representation your application promises to maintain; Cypress supplies the extraction primitives, but it does not prescribe an odometer’s DOM structure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Autosirs GPS Speedometer with Odometer for Car, Solar-Assisted MPH Display
  • GPS SPEEDOMETER WITH ODOMETER — View real-time MPH speed and total driving distance on one dashboard display. The X100 uses GPS satellite positioning and works without an OBD2 connection, making it easy to use across different vehicles.
  • SOLAR-ASSISTED RECHARGEABLE DESIGN — A built-in 1000mAh battery supports portable dashboard use, while the integrated solar panel provides supplemental charging in suitable sunlight. USB-C charging is also supported.
  • MORE THAN SPEED — In addition to GPS speed and odometer data, X100 displays altitude, time, date, satellite status and battery level, giving drivers useful trip information in one compact display.
  • DUAL SPEED ALERTS & AUTO BRIGHTNESS — Save two speed warning settings for different driving conditions. Automatic brightness adjusts the display based on ambient light for easier viewing during daytime and nighttime driving.
  • FOR CARS, TRUCKS & RVs — Designed for dashboard use in cars, pickups, SUVs, trucks, RVs, motorhomes and older vehicles. Suitable for commuting, highway driving, road trips and RV travel where a clear GPS speed reference is useful.
cy.get('[data-cy="odometer"]')
  .invoke('attr', 'aria-valuenow')
  .then(Number)
  .should('eq', 12345)

Do not confuse a live value with an HTML attribute that merely records an initial value. Confirm whether the selected attribute changes when the displayed reading changes.

Read a rolling-digit widget

Some animated odometers render each digit separately. They can also leave off-screen, duplicated, or transitional digit nodes in the DOM. Inspect the rendered markup and select only the nodes that represent the currently visible digits, in their visual order. The selector below is illustrative; data-digit="visible" is not a Cypress-defined convention.

cy.get('[data-cy="odometer"] [data-digit="visible"]')
  .then(($digits) =>
    [...$digits]
      .map((element) => element.textContent.trim())
      .join('')
  )
  .then(Number)
  .should('eq', 12345)

If the widget exposes one stable text node, accessible value, or canonical attribute, prefer that to querying animation internals. Tests tied to transient digit columns are more vulnerable to implementation changes.

Assert changing values without racing the animation

Keep the value extraction and assertion in a Cypress query chain so Cypress can retry while the interface updates. Cypress documents that .invoke() can be retried when chained assertions are attached, and its assertions retry until they pass or time out (Cypress invoke; Cypress assertions).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
OinDoDi Digital GPS Speedometer Heads Up Display for Cars New HUD MPH Odometer Trip Meter for Trucks Golf cart All Vehicles, 4.5 inch Big Screen, USB Cable Plug & Play (C80)
  • 【9-in-1 HUD】Heads up display, it has multifunctions - Vehicle driving speed, Driving time, Driving mileage, Total Mileage, Local time, Altitule, Over-speed alarm, Fatigue driving warning, freely switch between kilometers and miles.
  • 【GPS Speedometer】Collects the speed data from GPS satellites, no relation with car engine, no destroy to car circuit board or OBD port, and can be widely used on SUV ATV Pick-up Truck Scooter Golf Cart Bus Boat Train Bike Motorcycle...all vehicles.
  • 【USB Cable Plug & play】Power (5V) through USB port, no professional installation is required. Connect it with USB cable (in our gift box), then connect it to your car USB port or car adaptor, it can work directly. When car is on, it will be on; when car is off, it will be off automatically.
  • 【 Safety Use 】The case is made of ABS+PC, which is high temperature resistant anti-fire material. No built-in battery, no explosion/no burning hazard under high temperature.
  • 【4.5'' Clear LED screen】C80 HUD is equipped with a high definition 4.5'' LED screen, which displays the information more clearly than the windshield HUD. The light sensor enables auto-adjustable brightness for day & night-time driving. Also the big and green color fonts makes more easier and comfortable to read.

Wait for a target reading

For a counter expected to reach a known value, attach the expected numeric assertion directly to the extraction chain:

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => Number(raw.replace(/[^d.-]/g, '')))
  .should('eq', 12345)

A fixed delay is usually less robust than a retryable assertion: a delay can be too short on a slower run and unnecessarily long on a faster one. If the value never reaches the target, Cypress eventually reports the failed assertion at its configured timeout.

Compare before and after a user action

Use a static alias for the starting number when it must remain the original value after the page changes. Cypress aliases normally re-run their query; { type: 'static' } stores the value captured when the alias is created (Cypress variables and aliases).

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => Number(raw.replace(/[^d.-]/g, '')))
  .as('before', { type: 'static' })

cy.get('[data-cy="increment"]').click()

cy.get('[data-cy="odometer"]')
  .invoke('text')
  .then((raw) => Number(raw.replace(/[^d.-]/g, '')))
  .should((after) => {
    cy.get('@before').then((before) => {
      expect(after).to.be.greaterThan(before)
    })
  })

When comparing against a changed value, the assertion must continue to be evaluated as the display updates. If an assertion callback or nested command structure in your Cypress version does not provide the retry behavior you need, assert the known target reading directly or use a Cypress query/command pattern that retries the current value. Avoid converting once in a one-off .then() and treating that snapshot as proof that a later update has completed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Shkalacar Car HUD Headup Display KM/H MPH GPS Digital Speedometer with LED Large Font Display for Car Truck SUV Motorcycle
  • Car head-up display shows the driving speed in real time, with LED large font, clear and easy to view.
  • GPS and BeiDou dual mode positioning speed measurement, stable performance, quick speed refresh, no delay.
  • Equipped with shading plate, the display is not easily affected by light, and is clearly visible at day and night.
  • Small size and light weight, non-destructive installation, will not block the line of sight, to ensure the safety of driving.
  • USB plug and play, starts and stop with the car, suitable for car, truck, SUV, buses, motorcycles, etc.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common extraction failures

Symptom Likely cause Fix
The assertion compares a string with a number text() and val() return strings. Convert explicitly with Number, parseInt, or parseFloat according to the display format.
The result is NaN The text contains labels or separators, or normalization left an invalid string. Inspect the raw text, isolate the numeric portion, and make separator rules explicit before conversion.
A decimal is truncated parseInt was used. Use parseFloat or Number, and assert the expected precision.
A value with a comma is wrong The comma may be a decimal mark rather than a thousands separator. Normalize with the display’s locale rules; do not globally strip commas without confirming their meaning.
An input appears empty The test used text() rather than reading the input’s value. Use .invoke('val'), then convert the returned string.
The number flickers or includes extra digits The widget may render hidden or transitional digit elements. Inspect the DOM, target only visible digits, or read a stable canonical text/attribute instead.
The test passes intermittently during animation The assertion may be checking a stale snapshot or not retrying the current query. Keep extraction in the Cypress chain and attach a retryable assertion to the query.
The selector breaks after a visual redesign It depends on a class, layout, or text that changed. Use a dedicated data-cy or data-test selector.

Or skip the browser setup

If you need a screenshot of the rendered odometer rather than a Cypress numeric assertion, ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. For a simple capture:

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

See the ScreenshotNeo documentation for request options. Before a shot, it accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether it was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo and start with the free plan.

Frequently Asked Questions

Does Cypress return a number from .invoke('text')?

No. It returns the element’s text as a string; convert it before a numeric assertion.

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

Should I use parseInt for every odometer?

No. It is appropriate for integer displays but drops fractional digits. Use Number or parseFloat when decimals matter.

Can Cypress read digits that are animated separately?

Yes, if the test selects only the currently displayed digit nodes and joins them in order; the selector depends on the widget’s markup.

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.