Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Why Does Playwright Capture the Old Price on a Product Page?

A stale product price usually means the page is still updating or the test reads the wrong node or variant. Diagnose it with response waits and retryable locator assertions.

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.

Playwright usually captures an old price because the test reads it before the product page has finished updating, or because it reads the wrong price element or product variant. Wait for the relevant page state or price-changing response, then assert the intended visible price with a retryable locator. Without the page URL, selector, and test code, the exact cause cannot be confirmed.

Why the price can be stale

The page is visible before its JavaScript behavior is ready

Navigation completion and application readiness are different. A storefront can render initial HTML, including a provisional price, before client-side JavaScript hydrates the page and updates its interactive state. Playwright’s navigation documentation describes this distinction. A page being loaded or an element being visible does not by itself establish that the final price has appeared.

As an Amazon Associate I earn from qualifying purchases.

A variant selection triggers an asynchronous price change

Size, color, or another option may cause the storefront to request a new price. If the test reads the price immediately after selecting the option, it may get the previous variant’s value. Playwright documents waiting for a matching response with page.waitForResponse; the wait should be registered before the action that triggers the request.

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

The test reads a different price than the one the shopper sees

Product pages can show more than one amount, such as a crossed-out list price and a current sale price, or prices for multiple variants. A selector that matches more than one node, or a selector aimed at the wrong node, can return a valid but unintended value. Decide first whether the expected amount is for the default variant, the selected variant, or a particular displayed price.

Diagnose the cause in order

  1. Define the expected price. Record the intended variant and whether the test should read the sale price, list price, or another amount.
  2. Check the locator. Inspect how many elements it matches and whether it targets the visible current price rather than a crossed-out or hidden amount.
  3. Observe the page at both stages. Compare the relevant element after navigation with its state after hydration and after selecting the option. This shows whether the DOM changes after the initial render.
  4. Inspect the request and response. If selecting the option triggers a request, wait for the site-specific response and compare its payload with the rendered text. A response containing the expected amount while the page still shows the old one points to a rendering or timing issue; a response containing the old amount shifts attention to the selected variant or store behavior.
  5. Use a retryable assertion for the final state. Playwright locator assertions retry until the condition passes or times out. They help with transient updates, but they cannot decide which price is semantically correct; the assertion must name the intended value and target the correct locator.
  6. Investigate cache only with request evidence. Playwright documents that enabling routing disables HTTP cache. That can help examine request behavior, but it does not establish cache as the cause of a stale price. Changing routing may also alter test behavior.

Wait for a price-changing response, then verify the page

Use this pattern when selecting a variant causes a request. Replace the response predicate, option, locator, and expected price with values observed for the actual store. The example is a pattern, not a reproduction of a particular retailer.

const responsePromise = page.waitForResponse(response =>
  response.url().includes('/product-price') && response.status() === 200
);
await page.getByLabel('Size').selectOption('large');
const response = await responsePromise;
// Inspect response data as appropriate, then verify the intended visible price.
await expect(page.getByTestId('product-price')).toHaveText('$42.00');

The predicate is deliberately site-specific: use the actual endpoint or other reliable characteristics of the request. Starting the wait before the selection prevents the test from missing a fast response. The final locator assertion checks the rendered value, not merely that a request finished. See Playwright’s response-wait API and locator assertion guidance.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Why a fixed sleep is not a dependable fix

A fixed delay can make a test appear to work when the update usually finishes within that interval, but it does not prove the page reached the correct state. A slower response can still outlast the delay; a fast response simply makes the test wait unnecessarily. Prefer waiting for the specific response when one drives the change, followed by an assertion on the intended visible price.

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

Troubleshoot common outcomes

  • The response wait times out: confirm that selecting this option actually makes a request, and adjust the predicate to match the real URL and status. Register the wait before the selection.
  • The response arrives but the assertion times out: inspect whether the response data matches the expected amount and whether the page updates a different node or requires another state change.
  • The assertion passes with the wrong amount: check for multiple matching elements and clarify which variant and price type the test is meant to verify.
  • Routing changes the result: routing disables HTTP cache in Playwright. Compare the requests and responses in the original and routed test setups before attributing the behavior to cache.
  • The price changes without a matching request: inspect the DOM over time and the storefront’s client-side update behavior; the available evidence does not identify a universal wait condition for every site.

Or skip the browser setup

If you need a screenshot rather than a Playwright test of the page’s price logic, ScreenshotNeo is a website screenshot API and MCP server. A one-call capture can save a WebP image:

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 request options. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Playwright automatically wait for the product price to finish changing?

Locator assertions retry for the expected condition, but Playwright cannot infer which variant or price is correct. Assert the intended value on the correct locator.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Does a stale price prove the browser used a cached response?

No. Cache is one possibility to investigate using actual request and response evidence; a stale value alone does not establish it.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.