2016-12-19 16:39:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
const Page = require( './page' );
|
|
|
|
|
|
|
|
|
|
class CreateAccountPage extends Page {
|
|
|
|
|
|
|
|
|
|
get username() { return browser.element( '#wpName2' ); }
|
|
|
|
|
get password() { return browser.element( '#wpPassword2' ); }
|
|
|
|
|
get confirmPassword() { return browser.element( '#wpRetype' ); }
|
|
|
|
|
get create() { return browser.element( '#wpCreateaccount' ); }
|
|
|
|
|
get heading() { return browser.element( '#firstHeading' ); }
|
|
|
|
|
|
|
|
|
|
open() {
|
|
|
|
|
super.open( 'Special:CreateAccount' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createAccount( username, password ) {
|
|
|
|
|
this.open();
|
|
|
|
|
this.username.setValue( username );
|
|
|
|
|
this.password.setValue( password );
|
|
|
|
|
this.confirmPassword.setValue( password );
|
|
|
|
|
this.create.click();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 10:10:18 +00:00
|
|
|
apiCreateAccount( username, password ) {
|
|
|
|
|
|
2018-03-09 12:34:28 +00:00
|
|
|
const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
|
|
|
|
|
Promise = require( 'bluebird' );
|
|
|
|
|
let bot = new MWBot();
|
2017-05-08 10:10:18 +00:00
|
|
|
|
2018-03-09 12:34:28 +00:00
|
|
|
return Promise.coroutine( function* () {
|
|
|
|
|
yield bot.loginGetCreateaccountToken( {
|
|
|
|
|
apiUrl: `${browser.options.baseUrl}/api.php`,
|
|
|
|
|
username: browser.options.username,
|
|
|
|
|
password: browser.options.password
|
|
|
|
|
} );
|
|
|
|
|
yield bot.request( {
|
|
|
|
|
action: 'createaccount',
|
|
|
|
|
createreturnurl: browser.options.baseUrl,
|
|
|
|
|
createtoken: bot.createaccountToken,
|
|
|
|
|
username: username,
|
|
|
|
|
password: password,
|
|
|
|
|
retype: password
|
|
|
|
|
} );
|
|
|
|
|
} ).call( this );
|
2017-05-08 10:10:18 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-19 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
module.exports = new CreateAccountPage();
|