UNPKG

@wordpress/e2e-test-utils

Version:
37 lines (35 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loginUser = loginUser; var _config = require("./shared/config"); var _createUrl = require("./create-url"); var _isCurrentUrl = require("./is-current-url"); var _pressKeyWithModifier = require("./press-key-with-modifier"); /** * Internal dependencies */ /** * Performs log in with specified username and password. * * @param {?string} username String to be used as user credential. * @param {?string} password String to be used as user credential. */ async function loginUser(username = _config.WP_USERNAME, password = _config.WP_PASSWORD) { if (!(0, _isCurrentUrl.isCurrentURL)('wp-login.php')) { const waitForLoginPageNavigation = page.waitForNavigation(); await page.goto((0, _createUrl.createURL)('wp-login.php')); await waitForLoginPageNavigation; } await page.focus('#user_login'); await (0, _pressKeyWithModifier.pressKeyWithModifier)('primary', 'a'); await page.type('#user_login', username); await page.focus('#user_pass'); await (0, _pressKeyWithModifier.pressKeyWithModifier)('primary', 'a'); await page.type('#user_pass', password); await Promise.all([page.click('#wp-submit'), page.waitForNavigation({ waitUntil: 'networkidle0' })]); } //# sourceMappingURL=login-user.js.map