mercredi 5 juin 2019

How to get text content with puppeteer and test it

I am trying to scrap some text and than compare it in jest except.

my code returns:

expect(received).toBe(expected) // Object.is equality

Expected: "Forgot password"

Received: {}

describe('login to Synthrone tests', () => {
  test('no existed user try', async() => {

      browser = await puppeteer.launch(chromeOptions)
      const page = await browser.newPage();

      await page.goto("https://admin.manager.test-synthrone.com/") 
      const a  = page.evaluate(() => 
      document.querySelector(".additional-user-actions").textContent.trim());
      expect(a).toBe('Forgot password');

    })
  })

Aucun commentaire:

Enregistrer un commentaire