}
apiDelete( name, reason ) {
- const url = require( 'url' ), // https://nodejs.org/docs/latest/api/url.html
- baseUrl = url.parse( browser.options.baseUrl ), // http://webdriver.io/guide/testrunner/browserobject.html
- Bot = require( 'nodemw' ), // https://github.com/macbre/nodemw
- client = new Bot( {
- protocol: baseUrl.protocol,
- server: baseUrl.hostname,
- port: baseUrl.port,
- path: baseUrl.path,
+
+ const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
+ Promise = require( 'bluebird' );
+ let bot = new MWBot();
+
+ return Promise.coroutine( function* () {
+ yield bot.loginGetEditToken( {
+ apiUrl: `${browser.options.baseUrl}/api.php`,
username: browser.options.username,
- password: browser.options.password,
- debug: false
+ password: browser.options.password
} );
+ yield bot.delete( name, reason );
+ } ).call( this );
- return new Promise( ( resolve, reject ) => {
- client.logIn( function ( err ) {
- if ( err ) {
- console.log( err );
- return reject( err );
- }
- client.delete( name, reason, function ( err ) {
- if ( err ) {
- return reject( err );
- }
- resolve();
- } );
- } );
- } );
}
}