Skip to content

[Question] Issue with selecting text on the DOM #2024

@leovarmak

Description

@leovarmak

As you can see in the below snippet, I am trying to find the text Success. in the DOM, but asserting it always returns me an error.

let assert = require("assert");
const { chromium } = require("playwright");

(async () => {
  const browser = await chromium.launch({ headless: false });
  const browserContext = await browser.newContext();
  const browserPage = await browserContext.newPage();

  await createAccount(browserPage);
})();

const createAccount = async (page) => {
  await page.goto("https://coindcx.com/signup");
  await page.fill('input[name="firstName"]', "Test");
  await page.fill('input[name="lastName"]', "test");
  await page.fill('input[name="email"]', "[email protected]");
  await page.fill('input[name="password"]', "Qwerty@123");
  await page.fill('input[placeholder="Select Country"]', "India");
  await page.click('span[class="country__name -o-6"]');
  await page.fill(
    'input[name="phone"]',
    Math.floor(1000000000 + Math.random() * 900000).toString()
  );
  await page.click('button[type="submit"]');
  assert(await page.$(`text="Success"`));
};

Any tips would be really helpful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions