{"id":2805,"date":"2026-05-26T20:19:09","date_gmt":"2026-05-26T20:19:09","guid":{"rendered":"https:\/\/deathbycaptcha.com\/blog\/?p=2805"},"modified":"2026-05-26T21:59:15","modified_gmt":"2026-05-26T21:59:15","slug":"automating-captcha-submission-with-playwright-and-death-by-captcha","status":"publish","type":"post","link":"https:\/\/deathbycaptcha.com\/blog\/usage-best-practices\/automating-captcha-submission-with-playwright-and-death-by-captcha","title":{"rendered":"Automating Captchas with Playwright &#038; Death By Captcha"},"content":{"rendered":"<div class=\"fusion-fullwidth fullwidth-box nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\"  style='background-color: rgba(255,255,255,0);background-position: center center;background-repeat: no-repeat;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;'><div class=\"fusion-builder-row fusion-row \"><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"padding: 0px 0px 0px 0px;background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t<div class=\"fusion-text\"><p>Browser automation becomes significantly more powerful when combined with intelligent captcha solving. If your workflow involves solving a captcha and submitting it to a website, manually solving it quickly becomes inefficient. A more scalable approach is to combine our captcha solving API with <strong>Playwright<\/strong>. This article walks through how to implement that workflow using <strong>Node.js<\/strong>.<code><\/code><\/p>\n<h4><!-- obsidian --><\/h4>\n<\/div><br><div class=\"fusion-text\"><h4>The workflow in a nutshell<\/h4>\n<p>The first step is submitting the captcha to <a href=\"https:\/\/deathbycaptcha.com\/\">Death By Captcha<\/a> API, check if the token is ready by polling the API every 5 seconds until a token is returned, then the token is inserted into the hidden <code>textarea<\/code> element with ID <code>g-recaptcha-response<\/code> and finally the form needs to be submitted.<\/p>\n<p><strong>This is a high level view of the whole pipeline:<\/strong><\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-1 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_1\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/md\">ReCAPTCHA \u2192 Submit captcha to API \u2192 Poll API for solution token \u2192 Browser Automation \u2192 Submission<\/textarea><\/div><br><div class=\"fusion-text\"><h4 data-heading=\"Why Use Playwright for This Workflow?\"><\/h4>\n<h4 data-heading=\"Why Use Playwright for This Workflow?\">Why Use Playwright for This Workflow?<\/h4>\n<p>There are several browser automation frameworks available, but Playwright is especially well suited for modern API-driven automation.<\/p>\n<p><strong>a) Built-in async\/await support<\/strong><\/p>\n<h4><!-- obsidian --><\/h4>\n<p><!-- obsidian --><\/p>\n<p>The workflow reads clearly from top to bottom.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-2 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_2\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"elegant\" data-mode=\"text\/md\">await page.goto(...)await page.fill(...)await page.click(...)<\/textarea><\/div><div class=\"fusion-text\"><p>This makes automation scripts easier to maintain.<\/p>\n<p><strong>b) Cleaner browser interaction<\/strong><\/p>\n<p>Playwright provides direct methods for common form interactions such as:<\/p>\n<ul>\n<li>Filling fields<\/li>\n<li>Clicking buttons<\/li>\n<li>Waiting for page readiness<\/li>\n<\/ul>\n<p>This keeps your implementation concise.<\/p>\n<\/div><br><div class=\"fusion-text\"><h4>Understanding how to set up your own Playwright automation<\/h4>\n<p><strong>Note:<\/strong> We have added the full code at the bottom, this section is a high level overview of the overall Playwright workflow.<\/p>\n<h5>Stage 1: Configure client to solve the captcha<\/h5>\n<p>a) Either Integrate our <a href=\"https:\/\/github.com\/deathbycaptcha\/deathbycaptcha-api-client-nodejs\/blob\/master\/examples\/example.reCAPTCHA_v2.js\">existing Node.js client<\/a> with your own logic,<\/p>\n<p>b) or use the sample code at the bottom section of the article (you can read more about it&#8217;s internal functions and setup).<\/p>\n<h5>Stage 2: Install required dependencies<\/h5>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-3 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_3\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_3\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"1\" data-theme=\"hopscotch\" data-mode=\"text\/md\">npm install playwright\nnpx playwright install<\/textarea><\/div><div class=\"fusion-text\"><p>The <code>npm<\/code> dependency gives your Node.js application access to browser automation.<\/p>\n<p>The <code>npx<\/code> dependency is needed since it gives you the binaries, downloads the actual browsers Playwright controls:<\/p>\n<ul>\n<li>Chromium<\/li>\n<li>Firefox<\/li>\n<li>WebKit<\/li>\n<\/ul>\n<\/div><div class=\"fusion-text\"><h5>Stage 3: Configuring the Submission Target<\/h5>\n<p>The first part of the implementation defines the destination and selectors.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-4 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_4\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">const SUBMISSION_URL = \"https:\/\/www.google.com\/recaptcha\/api2\/demo\";<\/textarea><\/div><div class=\"fusion-text\"><p>And the page elements:<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-5 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_5\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">const SELECTORS = {\n  \/\/ add selectors here\n  submitButton: \"#recaptcha-demo-submit\"\n}<\/textarea><\/div><div class=\"fusion-text\"><p>Centralizing selectors makes updates easier if the page structure changes.<\/p>\n<\/div><div class=\"fusion-text\"><h5>Stage 4: Get the Captcha Result<\/h5>\n<p><!-- obsidian --><\/p>\n<p>Before interacting with the browser, your application needs to confirm that Death By Captcha API returned a token.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-6 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_6\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">const retrieveToken = async ()<\/textarea><\/div><div class=\"fusion-text\"><p>Its job is to:<\/p>\n<ul>\n<li>Return the token fetched<\/li>\n<li>Close the app on error<\/li>\n<\/ul>\n<p>This prevents invalid submissions.<\/p>\n<\/div><div class=\"fusion-text\"><h5 data-heading=\"Stage 2: Open the Submission Page\">Stage 5: Launch Chromium<\/h5>\n<p>Playwright launches Chromium (This creates a browser context ready for automation) and calls `submitToPage()` which receives Playwright context and which executes the submission to the page only if a token was successfully fetched.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-7 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_7\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">\u00a0const browser = await chromium.launch()<\/textarea><\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-8 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_8\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">const token = await retrieveToken()<\/textarea><\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-9 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_9\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">if (token) {\n\u00a0 \u00a0 \u00a0 const page = await browser.newPage()\n\u00a0 \u00a0 \u00a0 await submitToPage(page)\n\u00a0 \u00a0 \u00a0 console.log(\"Captcha solved successfully\")\n}<\/textarea><\/div><div class=\"fusion-text\"><h5 data-heading=\"Stage 3: Submit the Transcribed Text\">Stage 6: Submission of token &amp; form<\/h5>\n<p>The final step:<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-10 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_10\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"oceanic-next\" data-mode=\"text\/javascript\">const submitToPage = async (page) => {\n  await page.goto(SUBMISSION_URL)\n\n  await page.evaluate((value) => {\n    const el = document.querySelector(\"#g-recaptcha-response\")\n    el.value = value\n    el.dispatchEvent(new Event(\"input\", { bubbles: true }))\n  }, token)\n\n  await page.click(SELECTORS.submitButton)\n}<\/textarea><\/div><div class=\"fusion-text\"><p><code>submitToPage()<\/code><\/p>\n<ol>\n<li>Waits until Playwright goes to the submission URL<\/li>\n<li>To then Wait for the text area and token injection<\/li>\n<li>Waits until form gets submitted with a click on the submit button.<\/li>\n<\/ol>\n<p>This completes the workflow automatically.<\/p>\n<\/div><br><div class=\"fusion-text\"><h4>Complete code:<\/h4>\n<\/div><br><div class=\"fusion-text\"><p><strong>Step 1: Make sure your &#8216;<em>package.json&#8217;<\/em>\u00a0is set up correctly<\/strong><\/p>\n<p>Make sure:<\/p>\n<ul>\n<li>That &#8220;type&#8221; is set to &#8220;module&#8221; for ES6.<\/li>\n<li>To have <code>index.js<\/code> as your app entry point by setting &#8220;main&#8221;: &#8220;index.js&#8221;<\/li>\n<li>Have a &#8220;start&#8221; script which runs your Node.js app; &#8220;start&#8221;: &#8220;node index.js&#8221;.<\/li>\n<\/ul>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-11 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_11\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"1\" data-theme=\"oceanic-next\" data-mode=\"application\/json\">{\n  \"name\": \"playwrite_automation\",\n [...]\n  \"type\": \"module\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"node index.js\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  }\n}<\/textarea><\/div><div class=\"fusion-text\"><p><strong>Step 2: Install dependencies<\/strong><\/p>\n<p>Skip this step if you&#8217;ve already installed them in the previous section<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-12 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_12\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_12\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"1\" data-theme=\"hopscotch\" data-mode=\"text\/md\">npm install playwright\nnpx playwright install<\/textarea><\/div><div class=\"fusion-text\"><p><strong>Step 3: Use the code<\/strong><\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-13 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_13\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"hopscotch\" data-mode=\"text\/x-sh\">recaptcha-solver.js (DBC captcha solving)<\/textarea><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-14 > .CodeMirror .CodeMirror-gutters { background-color: ; }.fusion-syntax-highlighter-14 > .CodeMirror .CodeMirror-linenumber { color: ; }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-14 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_14\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_14\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"elegant\" data-mode=\"text\/javascript\">const API_URL = \"http:\/\/api.dbcapi.me\/api\/captcha\"\nconst USERNAME = \"your_username\"\nconst PASSWORD = \"your_password\"\n\nconst CAPTCHA_PARAMS = {\n  proxy: \"http:\/\/user:password@127.0.0.1:3128\", \/\/ leave empty if no proxy\n  proxytype: \"HTTP\",                            \/\/ leave empty if no proxy\n  googlekey: \"6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-\",\n  pageurl: \"https:\/\/www.google.com\/recaptcha\/api2\/demo\"\n}\n\nconst TYPE = 4\n\nconst submitCaptcha = async () => {\n  const formData = new FormData()\n\n  formData.append(\"username\", USERNAME)\n  formData.append(\"password\", PASSWORD)\n  formData.append(\"type\", TYPE)\n  formData.append(\"token_params\", JSON.stringify(CAPTCHA_PARAMS))\n\n  const response = await fetch(API_URL, {\n    method: \"POST\",\n    body: formData\n  })\n\n  if (!response.ok) {\n    throw new Error(`Submission to DBC failed: ${response.status}`)\n  }\n  const text = await response.text()\n  const params = new URLSearchParams(text)\n\n  return params.get(\"captcha\")\n}\n\nconst getToken = async (captchaId) => {\n  const response = await fetch(`${API_URL}\/${captchaId}`)\n\n  if (!response.ok) {\n    throw new Error(`Fetch failed: ${response.status}`)\n  }\n\n  return await response.text()\n}\n\n\/\/ Sleep helper\nconst delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))\n\nexport const solveCaptcha = async () => {\n  try {\n    console.log(\"Submitting captcha...\")\n    const captchaId = await submitCaptcha()\n\n    console.log(\"Solving captcha...\")\n    console.log(\"Captcha ID:\", captchaId)\n\n    const maxAttempts = 24\n\n    for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n      console.log(`Waiting 5 seconds before attempt ${attempt}...`)\n      await delay(5000)\n\n      console.log(`Checking result... Attempt ${attempt}`)\n\n      const result = await getToken(captchaId)\n      const params = new URLSearchParams(result)\n      const token = params.get(\"text\")\n\n      if (token.length > 1) {\n        console.log(\"Final response:\")\n        return {\n          success: true,\n          data: token\n        }\n      } else if (token === \"?\") {\n        return {\n          success: false,\n          error: \"Empty response.\"\n        }\n      }\n\n      console.log(\"Result not ready yet.\")\n    }\n    console.log(\"Timed out waiting for resolution.\")\n  } catch (error) {\n    return {\n      success: false,\n      error\n    }\n  }\n}<\/textarea><\/div><style type=\"text\/css\" scopped=\"scopped\"><\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-15 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_15\" data-readOnly=\"nocursor\" data-lineNumbers=\"\" data-lineWrapping=\"\" data-theme=\"hopscotch\" data-mode=\"text\/x-sh\">index.js (Playwright execution)<\/textarea><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-16 > .CodeMirror .CodeMirror-gutters { background-color: ; }.fusion-syntax-highlighter-16 > .CodeMirror .CodeMirror-linenumber { color: ; }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-16 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:10px;margin-left:0px;margin-bottom:10px;margin-right:0px;font-size:14px;border-width:1px;border-style:solid;border-color:#eaeaea;\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_16\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_16\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"1\" data-theme=\"elegant\" data-mode=\"text\/javascript\">import { solveCaptcha } from \".\/recaptcha-solver.js\"\nimport { chromium } from \"playwright\"\n\nconst SUBMISSION_URL = \"https:\/\/www.google.com\/recaptcha\/api2\/demo\"\n\nconst SELECTORS = {\n  \/\/ add selectors here\n  submitButton: \"#recaptcha-demo-submit\"\n}\n\nconst retrieveToken = async () => {\n  const response = await solveCaptcha()\n\n  if (!response.success) {\n    console.error(response.error)\n    return\n  }\n\n  console.log(response.data)\n  return response.data\n}\n\nconst token = await retrieveToken()\n\nconst submitToPage = async (page) => {\n  await page.goto(SUBMISSION_URL)\n\n  await page.evaluate((value) => {\n    const el = document.querySelector(\"#g-recaptcha-response\")\n    el.value = value\n    el.dispatchEvent(new Event(\"input\", { bubbles: true }))\n  }, token)\n\n  await page.click(SELECTORS.submitButton)\n}\n\nconst solvePageCaptcha = async () => {\n  const browser = await chromium.launch({\n    headless: false,\n  })\n\n  try {\n    if (token) {\n      const page = await browser.newPage()\n      await submitToPage(page)\n      console.log(\"Captcha solved successfully\")\n    }\n  } catch (error) {\n    console.error(\"Token submission failed:\", error.message)\n  } finally {\n    await browser.close()\n  }\n}\n\nsolvePageCaptcha()<\/textarea><\/div><div class=\"fusion-text\"><h4>Expected output:<\/h4>\n<\/div><div class=\"fusion-text\"><div style=\"width: 1240px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-2805-1\" width=\"1240\" height=\"698\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/deathbycaptcha.com\/blog\/wp-content\/uploads\/2026\/05\/playwright-output.mp4?_=1\" \/><a href=\"https:\/\/deathbycaptcha.com\/blog\/wp-content\/uploads\/2026\/05\/playwright-output.mp4\">https:\/\/deathbycaptcha.com\/blog\/wp-content\/uploads\/2026\/05\/playwright-output.mp4<\/a><\/video><\/div>\n<\/div><div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":2808,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[59,52],"tags":[],"class_list":["post-2805","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-useful-articles","category-usage-best-practices"],"_links":{"self":[{"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/posts\/2805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/comments?post=2805"}],"version-history":[{"count":81,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/posts\/2805\/revisions"}],"predecessor-version":[{"id":2898,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/posts\/2805\/revisions\/2898"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/media\/2808"}],"wp:attachment":[{"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/media?parent=2805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/categories?post=2805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deathbycaptcha.com\/blog\/wp-json\/wp\/v2\/tags?post=2805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}