mardi 4 décembre 2018

Clicking navigation button in Puppeteer returns null? How to see which function is being clicked?

I'm trying to test clicking a button on a registration app to make sure that the page correctly navigates to the right page.

When I console.log out response in the code it returns an array that looks like this

[undefined, null]

However when I take a screenshot of the page or check the url, the click and navigation worked. It is on the correct page.

I don't understand why this is returning undefined/null. Also, I could not figure out how to test which function was being called when you click on the button.

I wanted to be able to see the actual function that is being called.

I'm using AngularJS 1.6, Mocha, Puppeteer 1.11, and Node 6.4.0

I'm also a junior dev so it could be something simple that I just didn't understand, please help!

it('should rederict to guest_sms_code state when clicking \'I have a guest code\'', async (function () {
    var response = await (Promise.all([
        page.waitForNavigation({waitUntil: 'domcontentloaded'}),
        page.click('[ng-click="enterSmsCode()"]'),
      ]));
    var url = await (page.url());
    if (url.indexOf('guest_sms_code') === -1) {
        assert.ok(false, 'The URL does not contain \'guest_sms_code\'')
    }
}))

Aucun commentaire:

Enregistrer un commentaire