Tricky “password” field in WordPress install scrip

2019-08-20 19:12发布

问题:

I'm trying to use WordPress CodeCeption to run a script to install WordPress. I'm using PHPBrowser which is a headless browser.

Here is my script:

<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Setup WordPress');
$I->amOnPage("/wp-admin/setup-config.php?step=1");
$I->see("Below you should enter your database connection details.");
$I->fillField('dbname', 'wordpress_unit_test');
$I->fillField('uname', 'wordpressuser');
$I->click('.button');
$I->click('.button');
$I->fillField('weblog_title', 'AWS Remote Dev Server');
$I->fillField('user_name', 'admin');
$I->fillField('#pass1-text', 'password');
$I->fillField('admin_email', 'admin@email.com');
$I->click('.button');

It's getting hung up on the password field in the WP install screen. Any idea how to fill this field? I've tried:

$I->fillField('pass1-text', 'password');
$I->fillField('#pass1-text', 'password');

But I keep getting:

 Test  tests/runner/SetupWordPressCept.php
 Step  Fill field "#pass1-text","password"
 Fail  Form field by Label or CSS element with '#pass1-text' was not found.

回答1:

PHPBrowser does not support JavaScript, so if you want to check how this page looks for PHPBrowser, you should disable scripts in your browser (for example with NoScript).

In this case pass1 is a ID and admin_password is a name:

$I->fillField('admin_password', 'password');