Tricky “password” field in WordPress install script using CodeCeption

陌路散爱 提交于 2019-12-12 04:04:42

问题


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');


来源:https://stackoverflow.com/questions/45439608/tricky-password-field-in-wordpress-install-script-using-codeception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!