l2aelba l2aelba - 28 days ago 12
Node.js Question

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

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

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

describe('Submit form', function() {
before(function() {
browser.fill('#user_login', 'my_username').fill('#user_pass', 'my_password');
return browser.pressButton('#wp-submit');
});

it('Should be successful', function() {
console.log(browser.text('title')); // My Wordpress ‹ Log In
//browser.assert.success();
});
});
});


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 ?

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.