Merge "mediawiki.language: Implement non-digit-grouping of four-digit numbers"
[lhc/web/wiklou.git] / tests / selenium / pageobjects / edit.page.js
index 25da8cb..33a27f0 100644 (file)
@@ -19,25 +19,20 @@ class EditPage extends Page {
        }
 
        apiEdit( name, content ) {
-               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,
-                               debug: false
-                       } );
 
-               return new Promise( ( resolve, reject ) => {
-                       client.edit( name, content, `Created page with "${content}"`, function ( err ) {
-                               if ( err ) {
-                                       return reject( err );
-                               }
-                               resolve();
+               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
                        } );
-               } );
+                       yield bot.edit( name, content, `Created page with "${content}"` );
+               } ).call( this );
+
        }
 
 }