How to login into the Wordpress admin with zombie.js?

169 views Asked by At

I am trying to login in to my Wordpress site but seems like the login cannot be successful.

describe('Administrator', function(){
    const browser = new Browser();
    this.timeout(10000);
    before(function() {
        return browser.visit(baseUrl+'wp-login.php');
    });

    it('Login into wp-admin', function(done){
        browser.fill('#user_login', 'my_username')
               .fill('#user_pass', 'my_password')
               .pressButton('#wp-submit',
        function(){
            console.log(browser.text('title')); // My Wordpress ‹ Log In
            //browser.assert.element('body.wp-admin');
            //done();
        });
    });

    after(function() {
        browser.destroy();
    });
});

When I do log by browser.text('title')

its return My Wordpress ‹ Log In not Dashboard ‹ My Wordpress

That means it doesn't succeed. I try to use wait(), then(), setTimeout() before checking so its error like :

Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.

Any idea ?

1

There are 1 answers

1
Matt Lavin On BEST ANSWER

I tried to reproduce your problem by running your example code against https://demos1.softaculous.com/WordPress/wp-login.php. I saw that zombie was pegging the CPU at 100% while trying to find visible/hidden elements on the page.

I opened, and fixed, https://github.com/assaf/zombie/issues/1086 to dramatically improve the performance of zombie on that particular WordPress site.

You should try again using zombie > 5.0.2 to see if your WordPress site was causing the same high CPU behavior.